Skip to content
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

Merged
merged 7 commits into from
Jul 20, 2020

Conversation

itsrainingmani
Copy link
Contributor

@itsrainingmani itsrainingmani commented Jul 19, 2020

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.

@itsrainingmani itsrainingmani changed the title feat(athena) - scroll search results with arrow keys feat(athena): scroll search results with arrow keys Jul 19, 2020
src/cljs/athens/views/athena.cljs Outdated Show resolved Hide resolved
src/cljs/athens/views/athena.cljs Outdated Show resolved Hide resolved
src/cljs/athens/views/athena.cljs Outdated Show resolved Hide resolved
src/cljs/athens/views/athena.cljs Outdated Show resolved Hide resolved
itsrainingmani and others added 5 commits July 19, 2020 21:00
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>
* Move is-beyond-rect? into utils.cljc

* Add comments to the key up code

* Refactor the result-el selector
@itsrainingmani
Copy link
Contributor Author

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

Copy link
Collaborator

@tangjeff0 tangjeff0 left a 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).

Comment on lines +212 to +213
;; Get the result list container which is the last element child
;; of the whole athena component
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@tangjeff0 tangjeff0 merged commit 342d991 into athensresearch:master Jul 20, 2020
korlaism pushed a commit to korlaism/athens that referenced this pull request Jul 19, 2021
* 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>
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.

Athena Result list does not scroll when navigating with arrow keys
2 participants