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

fix(boxai-sidebar): Arrow Key Navigation on Suggested Questions #3865

Merged
merged 3 commits into from
Jan 30, 2025

Conversation

DanilaRubleuski
Copy link
Contributor

Description

Using the up and down arrow keys for keyboard navigation while focused on suggested questions also changes the document page.

Steps to Reproduce:

  1. Focus on the suggested questions section.
  2. Use the up or down arrow keys for navigation.
  3. The page unexpectedly changes as well.

To prevent this behavior callback with stopPropagation() was provided

Recording

Screen.Recording.2025-01-24.at.17.08.31.mov

@DanilaRubleuski DanilaRubleuski requested a review from a team as a code owner January 24, 2025 16:11
Copy link
Contributor

@jankowiakdawid jankowiakdawid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be a fix(boxai-sidebar)?

Comment on lines 97 to 107
const handleKeyPress = React.useCallback((event: KeyboardEvent) => {
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
event.stopPropagation();
}
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a storybook interactive test for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will do!

@DanilaRubleuski DanilaRubleuski changed the title feat(boxai-sidebar): Arrow Key Navigation on Suggested Questions fix(boxai-sidebar): Arrow Key Navigation on Suggested Questions Jan 24, 2025
@DanilaRubleuski DanilaRubleuski force-pushed the box-ai-sidebar-arrows-fix branch from 924c0ce to b838924 Compare January 29, 2025 10:03
@@ -94,6 +94,20 @@ const BoxAISidebar = (props: BoxAISidebarProps) => {
questionsWithoutInProgress = questionsWithoutInProgress.slice(0, -1);
}

const handleKeyPress = React.useCallback((event: KeyboardEvent) => {
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about Down and Up arrows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug appears only for Left and Right arrow keys, for the Arrow Up/Down it's not being propagated further

@DanilaRubleuski DanilaRubleuski force-pushed the box-ai-sidebar-arrows-fix branch from 2a947d6 to 5a69aec Compare January 29, 2025 13:51
@DanilaRubleuski DanilaRubleuski force-pushed the box-ai-sidebar-arrows-fix branch from 7c74dfb to 40939fe Compare January 30, 2025 19:46
@mergify mergify bot merged commit 560fee0 into box:master Jan 30, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants