Closed ddrury closed 2 years ago
The problem in function webtrees.persistentToggle
is that localStorage.getItem()
returns null for a non-existent item, therefore the line if (previous_state !== current_state) {
will be true thus clicking the element.
Changing the line
var previous_state = localStorage.getItem(key);
to
var previous_state = localStorage.getItem(key) || 'false';
solves the problem
(or change the string representation of boolean values to proper booleans)
Maybe I'm being really stupid (likely!) but why not just use
if (localStorage.getItem(key) === 'true') {
element.click();
}
change the string representation of boolean values to proper booleans
The aria-expanded
attribute is a string ("true"
or "false"
), so we need to convert one way or the other...
but why not just use
I want this to work with with things that are initially expanded as well as initially collapsed.
I think we just need to check whether the previous value is not-null...
Since commit https://github.com/fisharebest/webtrees/commit/f0ecc9a9ae19c64e946ac4b65cc1bb4ff475956e all the checkboxes (Associated events, Events of close relatives, Historic events, Date differences, Show all * etc) default to checked whereas prior to this commit the default was unchecked which I preferred.