[theme demo] Fix dropdown losing choice on solarized light / dark #14280

Merged
marijnh merged 1 commit from github/fork/cben/theme-demo-location-hash into master 2025-03-11 15:35:55 +01:00
marijnh commented 2025-03-11 14:52:07 +01:00 (Migrated from gitlab.com)

Mild bug in demo due to space handling.

Before: https://codemirror.net/5/demo/theme.html#solarized%20dark

  1. dropdown .value set to non-existant solarized%20dark => dropdown reset to blank.
  2. picking solarized dark / light from dropdown changes theme (correctly sets .cm-s-solarized .cm-s-dark classes),
    sets URL fragment to #solarized%20dark (implicitly encoded by browser?¹),
    which again triggers dropdown reset to blank (1).
  3. can't iterate all dropdown values by Down/Up arrow: once you reach solarized, (2) happens

After: https://raw.githack.com/cben/CodeMirror5/theme-demo-location-hash-DEBUG/demo/theme.html#solarized%20dark (from debug branch with extra console logging)

¹ ² This commit makes both setting and getting URL fragment reliable.

Mild bug in demo due to space handling. Before: https://codemirror.net/5/demo/theme.html#solarized%20dark 1. dropdown .value set to non-existant `solarized%20dark` => dropdown reset to blank. 2. picking solarized dark / light from dropdown changes theme ([correctly](https://codemirror.net/doc/manual.html#option_theme) sets `.cm-s-solarized .cm-s-dark` classes), sets URL fragment to `#solarized%20dark` (implicitly encoded by browser?¹), which again triggers dropdown reset to blank (1). 3. can't iterate all dropdown values by Down/Up arrow: once you reach solarized, (2) happens After: https://raw.githack.com/cben/CodeMirror5/theme-demo-location-hash-DEBUG/demo/theme.html#solarized%20dark (from [debug branch](https://github.com/cben/CodeMirror5/commits/theme-demo-location-hash-DEBUG/) with extra console logging) ¹ ² This commit makes both setting and getting URL fragment reliable.
marijnh commented 2025-03-11 15:35:50 +01:00 (Migrated from gitlab.com)

Thanks for fixing that!

Thanks for fixing that!
marijnh commented 2025-03-11 15:35:55 +01:00 (Migrated from gitlab.com)

Merged by: marijnh at 2025-03-11 14:35:55 UTC

*Merged by: marijnh at 2025-03-11 14:35:55 UTC*
marijnh (Migrated from gitlab.com) merged commit into master 2025-03-11 15:35:55 +01:00
marijnh (Migrated from gitlab.com) closed this pull request 2025-03-11 15:35:56 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/codemirror5!14280
No description provided.