Skip to content

Commit

Permalink
fix(dropdown): add namespace to sessionstorage
Browse files Browse the repository at this point in the history
Whenever more than 1 dropdown is using remoteData, the sessionstorage is sharing the keys because of a missing namespace.
Now, if different dropdowns use the same ids, but different values then the second dropdown will return the wrong names from the first dropdown.
This PR adds the dropdowns id/namespace to the sessionstorage keys, so those are now unique to their respective dropdowns.

Example
Dropdown 1 has the following elements (key, value)
1, monday
2, tuesday
3, wednesday

Dropdown 2 has the following elements (key, value)
1, january
2, february
3, march

The second dropdown will get the Weeknames out of the sessionstorage instead of the monthnames, because the keys are the same.
  • Loading branch information
lubber-de committed Aug 10, 2021
1 parent 89fb963 commit 3eadf38
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -2324,7 +2324,7 @@ $.fn.dropdown = function(parameters) {
module.error(error.noStorage);
return;
}
name = sessionStorage.getItem(value);
name = sessionStorage.getItem(value + elementNamespace);
return (name !== undefined)
? name
: false
Expand Down Expand Up @@ -2368,7 +2368,7 @@ $.fn.dropdown = function(parameters) {
return;
}
module.verbose('Saving remote data to session storage', value, name);
sessionStorage.setItem(value, name);
sessionStorage.setItem(value + elementNamespace, name);
}
},

Expand Down

0 comments on commit 3eadf38

Please sign in to comment.