Skip to content

search word on double-click + persist page state via URL hash#17

Open
glowinthedark wants to merge 6 commits intoitkach:masterfrom
glowinthedark:state-store-url-hash
Open

search word on double-click + persist page state via URL hash#17
glowinthedark wants to merge 6 commits intoitkach:masterfrom
glowinthedark:state-store-url-hash

Conversation

@glowinthedark
Copy link
Copy Markdown

@glowinthedark glowinthedark commented Nov 18, 2023

  1. Store current dictionary and lookup word in the top page URL hash to allow persisting state on page refresh.

Allows reopening a specific article with the lookup word via a top frame URL like

With this change clicking refresh in the browser will allow the page state to survive, and the original search and definition to be shown rather than a reset to original empty state. Moreover, this allows bookmarking definitions in a specific dictionary.

  1. Double-clicking a word in the content frame initiates a lookup and opening 1st result in the content frame and searching the double-clicked word in the current dictionary.

  2. After a lookup open first entry in content frame

Store current dictionary and lookup word in the top page URL hash to allow persisting state on page refresh.

Allows reopening a specific article with the lookup word via a top frame URL like 

- http://127.0.0.1:8013/#/slob/c52148ef-0ac7-47cf-bd0f-c503552ebdd7/awake?blob=155-10&q=awake
@glowinthedark
Copy link
Copy Markdown
Author

glowinthedark commented Nov 18, 2023

@itkach let me know if you think it's an issue and if you think the two points addressed by this PR must go separately

regarding double-clicking on a word: currently this will open the double-clicked word in the 1st dictionary that appears in search (if any); do you think it might make sense to have double-click trigger a lookup in the same dictionary rather than the first one in the list?

Update: doubleclick action has been updated to emulate a link click in the current dictionary only — this imo is a more expected behaviour and also does not require setting directly the iframe content src as it was done in the original commit 7a842db


Update 2: this change is messing up the history and back/forward don't work as expected, given that with frames the page has two histories: top-level history and the frame's own history; updating the URL hash apparently triggers a history push state for the top frame and this messes up the back/forward behaviour, given that with an unchanged top-frame history the history buttons act on the nested frame history rather than top-frame

not clear what would be the best approach to have the history working properly, apart from getting rid of frames entirely and use instead a DIV for rendering content.

change doubleclick behaviour to search in the current dictionary only
@glowinthedark glowinthedark changed the title persist and reload page state on page via URL hash + search on double-click search on word double-click + persist page state via URL hash Nov 18, 2023
@glowinthedark glowinthedark changed the title search on word double-click + persist page state via URL hash search word on double-click + persist page state via URL hash Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant