Navigate word lookup in sc-bottom-sheet.js using arrow keys#3345
Navigate word lookup in sc-bottom-sheet.js using arrow keys#3345transducer wants to merge 1 commit into
Conversation
Reviewer's Guide by SourceryThis PR implements keyboard navigation for word lookup in the bottom sheet using the left and right arrow keys. It also updates the help text to reflect this change. The original access key functionality is preserved. Sequence diagram for bottom sheet keyboard navigationsequenceDiagram
actor User
participant BS as Bottom Sheet
participant KH as Keyboard Handler
participant Nav as Navigation Logic
User->>BS: Press Arrow Key
BS->>KH: _handleKeydown(event)
alt Arrow Left
KH->>Nav: _handleArrowLeftKeydown()
Nav->>Nav: _previous()
else Arrow Right
KH->>Nav: _handleArrowRightKeydown()
Nav->>Nav: _next()
end
Nav-->>BS: Update current word
BS-->>User: Display new word
Class diagram for SCBottomSheet changesclassDiagram
class SCBottomSheet {
-Object _keydownHandlers
+connectedCallback()
+disconnectedCallback()
-_handleKeydown(event)
-_handleArrowLeftKeydown()
-_handleArrowRightKeydown()
-_previous()
-_next()
}
note for SCBottomSheet "Added keyboard navigation
handlers for arrow keys"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
- Keydown handling similarly implemented as sc-top-sheet-view.js - Update Help text and add to local English translation
|
Interesting. Without your PR, alt n does nothing for me on FF and alt b triggers the browser's bookmark interface. So for sure that needs to be fixed. Generally we seem to avoid having two ways of doing things, so I doubt Bhante @sujato will want to do arrow keys and alt b/n. There has also been talk of using the arrow keys for navigating to the previous and next suttas. In fact the browser extension does just that. Thank you for working on this! Bhante @sujato is traveling atm so it may take a little bit for him to respond. |
|
Thank you. I agree a single way of doing things would be best, though in this case some keyboards don't have (easy to use) arrow keys so then it would make sense to support both arrow keys and b and n. Though in this case arrow keys possibly already have the intended purpose of moving between suttas.
For now the access keys don't work then for both of us for some reason. According to my LLM it should be accessKey in React JSX, not lower case. I will try tomorrow and possibly send a different PR. (Update today: this was a hallucination and doesn't matter.) An alternative would be only b or n keydown (without the access key modifier).
I'll wait for reply on how to proceed here.
Op za 28 dec. 2024 19:17 schreef thesunshade ***@***.***>:
… Interesting. Without your PR, alt n does nothing for me on FF and alt b
triggers the browser's bookmark interface. So for sure that needs to be
fixed.
Generally we seem to avoid having two ways of doing things, so I doubt
Bhante @sujato <https://github.com/sujato> will want to do arrow keys
*and* alt b/n.
There has also been talk of using the arrow keys for navigating to the
previous and next *suttas*. In fact the browser extension
<https://discourse.suttacentral.net/t/a-browser-extension-for-suttacentral/36074>
does just that.
Thank you for working on this! Bhante @sujato <https://github.com/sujato>
is traveling atm so it may take a little bit for him to respond.
—
Reply to this email directly, view it on GitHub
<#3345 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGFNKP7DM6GYYHJCMT2J7T2H3TKNAVCNFSM6AAAAABUJZMS26VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRUGM4TKMJRGM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
Thanks for the hot key reference, these are indeed the same as defined in sc-top-sheet-view.js. I notice now that actually the backward access key (Alt+b) does work in Firefox, only the forward (Alt+n) does not. The Ctrl+n (in my case the modifier is Ctrl+⌥ Opt) I think conflicts in Firefox with other behaviour. In Chrome it actually does work for me. Since I don't see access keys used anywhere else in the SuttaCentral applications, they are quite hard to discover and can conflict with other browser behaviour, maybe best to not use access keys and introduce new regular hot keys for navigating the word lookup? But what keys to use if the arrow keys and n (toggle notes view) are already taken? Perhaps just like in vi the h and l keys for going left and right one word, though this is not so discoverable. Or maybe overload the arrows keys that when the sc-bottom-sheet-view.js is open they are used for navigating the word lookup instead of the suttas? (Though I don't think the latter is technically feasible if the capturing of arrow keys comes from an extension, but if the hotkeys are all defined in the main application it should be possible to arrange it like that.) |
|
Hey @thesunshade, you commented on this. Do you think it is still relevant or can I close it? |
|
No idea! Would be good if it could get resolved |

For me the approach mentioned under help for navigating the bottom sheet using HTML access keys doesn't work. This PR should maintain the original functionality using HTML access keys and also provide functionality to navigate respectively left or right one word on the pressing of ← and →. I think this is more discoverable.
Goes right one word on pressing right and left one word on pressing left.
Updated help display.
Please let me know if this is a desired implementation or not and if I should add a unit test. And if desired maybe a good idea to also add a keydown handler for p (for previous word) and n (for next word)?
Also need to update the translations files found here.
Summary by Sourcery
New Features: