amtgard / ORK3

Version 3 of the Online Record Keeper
Other
23 stars 12 forks source link

Playerheraldry page incorrectly reading expanded container state - can cause page to disappear #105

Open p0lar-bear opened 7 years ago

p0lar-bear commented 7 years ago

Browsing ORK3 with Google Chrome 54.0.2840.99 on Windows 10, and Google Chrome 54.0.2480.85 on Android 7.0.

On the Reports/playerheraldry route (e.g. when viewing a park's list of player heraldries), if you expand or collapse an item, navigate away and back, the wrong elements will be expanded or collapsed.

This is due to what could be considered misuse of the info-container class on the page, or by using too broad of a selector or no filters in the jQuery.each() call on line 135 of orkui/template/default/script/default.js.

The click handler on line 138 of the same file is designed to store the open/closed state into LocalStorage under a key that's the index of the info-container within its containing element in the DOM. This works fine everywhere else, but when it comes time to reapply the states to the playerheraldry page, all of the states are reapplied offset by 1 because the jQuery.each() call on line 135 also includes the info-container wrapping the other info-containers.

This has a nasty side-effect of hiding the entire list if the first heraldry item is collapsed and the page is reloaded. And the only ways to get it back is to delete the browser's Local Storage for amtgard.com, or to use developer tools to edit the Local Storage and set "0" to "open".

First load: image

Click third item (Redbeard Stormblade Esquire): image

Reload page: image

Click first item (Pagan Darcborne): image

Reload page: image

The simplest fix would be to get rid of the info-container wrapping the player heraldry items. However, I feel it would be much better practice going forward to have all collapsible info containers given an id attribute, and to store open/closed states under those element IDs than an index.