Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

The new page is not highlighted in the left panel


Reply


7 Posts   1590 Views

Avatar
xmedeko

Community Member, 94 Posts

3 July 2007 at 5:54pm

Hi,
do you have the same weird behaviour? When I create a new page and click on this page in the left panel, then this page is not highlighted, but appears correctly in the right panel. In the left panel, the home page is highlighted usually.

I use FF 2.0 under Linux.

cheers
andy

Avatar
Nathan Cox

Community Member, 99 Posts

4 July 2007 at 2:18am

Edited: 04/07/2007 2:27am

Yeah, this behaviour's been bugging me for awhile, so I had a look at it. The problem is that the regular expression that that's used to get the ID of the item you're highlighting doesn't understand the IDs given to new pages before they're saved.

A regular ID looks like "record-1" (which is the homepage), but a newly created page has an ID like "record-new-Page-0-1" which is the first - number 1 - new page in the page root (which has an ID of 0).

What the regex does is take everything after the final "-" in the ID, which ends up with "1" for both the examples above, hence the problem.

Now I'm no regex expert, so this probably isn't the best way but it seems to fix the problem if you go into /jsparty/tree/tree.js, and change about line 497 from

if(this.id.match(/-([^-]+)$/)) return RegExp.$1;

to

if(this.id.match(/([^-]+)-(.+)$/)) return RegExp.$2;

What this does is get everything after the FIRST "-" instead of the last one, so the homepage above will still return "1", but the new page will return "new-Page-0-1", which is what we want.

Then again there might be a reason why it works like it does...

Avatar
elijahlofgren

Google Summer of Code Hacker, 222 Posts

4 July 2007 at 9:37am

Edited: 04/07/2007 9:39am

Andy: Thanks for reporting this.

Nathan: Thanks for fixing this! You also fixed a Usability Issue and saved me some work. :)

I've applied your fix to the gsoc branch of jsparty:
------------------------------------------------------------------------
r37735 | elofgren | 2007-07-03 16:33:15 -0500 (Tue, 03 Jul 2007) | 5 lines

BUGFIX: Fix bug 'The new page is not highlighted in the left panel'
Reported and fixed here: http://www.silverstripe.com/bugs/flat/1895
Thanks xmedeko and nathancox!
Also fixes usability issue #26: http://www.elijahlofgren.com/silverstripe/use-bold-highlighting-when-creating-new-pages/

------------------------------------------------------------------------

Thanks again,

Elijah

Avatar
Tim

Core Development Team, 201 Posts

4 July 2007 at 9:46am

Thanks for looking into this, this has been bugging me for some time as well :-)

Avatar
Tim

Core Development Team, 201 Posts

4 July 2007 at 9:59am

Another bug which may (or may not) be related to this;

If you click go to add a page, and try and add say 15 pages in quick succession (by pressing the go button every second or so), the 'parent' page seems to be randomly selected as the new pages gets placed in a number folders, seemingly at random.

Avatar
xmedeko

Community Member, 94 Posts

4 July 2007 at 10:23am

Nathan: thanks very much.

Did somebody examine the other similar regexps in the tree.js? (lines 69, 220). Should they be changed as well?

Avatar
Nathan Cox

Community Member, 99 Posts

4 July 2007 at 11:26am

I haven't noticed any problems that those other regexes could be causing, but then again I just don't want to go back into the JavaScript.
Complex JavaScript like this is what makes me lock my doors at night, so I might stick to the PHP :)