-
-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(athena): scroll search results with arrow keys #280
feat(athena): scroll search results with arrow keys #280
Conversation
WIP implementation of scrolling on arrow key using scrollIntoView. This implementation also prevents navigating beyond the first or last element (no cycling through the list) Co-authored-by: Adrien Lacquemant <github@alaq.io> Co-authored-by: nthd3gr33 <codinginenglish@gmail.com>
…re's only one logical branch being used Co-authored-by: Adrien Lacquemant <github@alaq.io> Co-authored-by: nthd3gr33 <codinginenglish@gmail.com>
…ult. chore: refactor code to use e.target and element.closest instead of css selectors Co-authored-by: Adrien Lacquemant <github@alaq.io> Co-authored-by: nthd3gr33 <codinginenglish@gmail.com>
Co-authored-by: Adrien Lacquemant <github@alaq.io> Co-authored-by: nthd3gr33 <codinginenglish@gmail.com>
Co-authored-by: Adrien Lacquemant <github@alaq.io> Co-authored-by: nthd3gr33 <codinginenglish@gmail.com>
6fe8569
to
35b4e47
Compare
* Move is-beyond-rect? into utils.cljc * Add comments to the key up code * Refactor the result-el selector
35b4e47
to
c2830ca
Compare
Hi @tangjeff0 . I've made the required changes. The only thing I'm a little unsure of is how much commenting the event handler needed. So let me know if it's too much |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job, we can now use this improved selection UX in a few more places like slash commands and inline search! Minor comments, but they can be handled in a larger HTML id+class refactor (which an issue should be made for).
;; Get the result list container which is the last element child | ||
;; of the whole athena component |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes a lot more sense to me now. I'm pretty sure I wrote [:div.athena]
, but that should probably be an HTML id. .athena
also doesn't do anything functionally, so maybe not that useful.
This could also be simplified if we just gave an HTML id/class to the results list directly, but not important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tangjeff0 Agreed on the HTML id thing. I think using id's all over the place might be overkill but could be very useful in simplifying the logic in cases where we need to access very commonly used elements.
* fix athena - scroll on arrow key navigation WIP implementation of scrolling on arrow key using scrollIntoView. This implementation also prevents navigating beyond the first or last element (no cycling through the list) Co-authored-by: Adrien Lacquemant <github@alaq.io> Co-authored-by: nthd3gr33 <codinginenglish@gmail.com> * fix athena: remove redundant do stmts and change if to when since there's only one logical branch being used Co-authored-by: Adrien Lacquemant <github@alaq.io> Co-authored-by: nthd3gr33 <codinginenglish@gmail.com> * feature: wrap around list when you reach the first or last search result. chore: refactor code to use e.target and element.closest instead of css selectors Co-authored-by: Adrien Lacquemant <github@alaq.io> Co-authored-by: nthd3gr33 <codinginenglish@gmail.com> * Move bounds checking code into its own function Co-authored-by: Adrien Lacquemant <github@alaq.io> Co-authored-by: nthd3gr33 <codinginenglish@gmail.com> * Refactor the control flow for scrollIntoView to be simpler Co-authored-by: Adrien Lacquemant <github@alaq.io> Co-authored-by: nthd3gr33 <codinginenglish@gmail.com> * feat(athena): Remove unnecessary comments * Move is-beyond-rect? into utils.cljc * Add comments to the key up code * Refactor the result-el selector Co-authored-by: Adrien Lacquemant <github@alaq.io> Co-authored-by: nthd3gr33 <codinginenglish@gmail.com> Co-authored-by: jeff <tangj1122@gmail.com>
This PR closes #271 and checks off part of #126
Athena can now scroll through the search results with arrow keys. The implementation also cycles through the search result list.