Skip to content

Conversation

mdhmaiti
Copy link
Contributor

@mdhmaiti mdhmaiti commented Mar 7, 2024

Closes #5996

✅ Pull Request Checklist:

📝 Test Instructions:

  1. run locally and navigate to the useTabList in the storybook.
  2. try to move between the tabs using arrow keys.
  3. Here I added restrictions to the upper arrow key and lower arrow key to solve the issue .

🧢 Your Project:

Added the horizontal orientations in the TabsKeyboardDeligate to prevent moving of tabs using upper and lower arrow keys

@snowystinger
Copy link
Member

Thanks for the PR! To answer some of your questions from the Issue, it should be your Github login for the CLA.

It would also appear that you have prettier or some auto formatted enabled because some files changed which I don't think you meant to change. It would be good to revert all the unrelated style changes so we can focus on the actual changes for the PR.

You can see how each of the ci steps are run by looking in the circle config file, package.json, and makefile. As for getting them to pass, if you look at the test that failed, you'll see that we're testing for the bad behavior

/** Changes selection regardless if it's horizontal tabs. */
so you should be able to just assert that up/down doesn't move focus for horizontal tabs

@mdhmaiti
Copy link
Contributor Author

mdhmaiti commented Mar 8, 2024

Thanks for helping me. I will fix my code

@LFDanLu
Copy link
Member

LFDanLu commented Mar 8, 2024

GET_BUILD

Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I'm double checking the behavior we want here via #5996 (comment) so we'll be holding off on any further changes until we can confirm that.

As an aside, if this is indeed the behavior we want, we'll also need to modify useSelectableCollection to only conditionally prevent default behavior on various keydown events. As it is now, the changes in this PR actually aren't sufficient to allow ArrowUp/Down to scroll the page when the TabList's orientation is 'horizontal'

@rspbot
Copy link

rspbot commented Mar 8, 2024

@rspbot
Copy link

rspbot commented Mar 8, 2024

## API Changes

unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any', access: 'private' }
unknown top level export { type: 'any', access: 'private' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'identifier', name: 'Column' }
unknown top level export { type: 'identifier', name: 'Column' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }

@mdhmaiti
Copy link
Contributor Author

mdhmaiti commented Mar 9, 2024

getKeyBelow(key: Key) { if (this.tabDirection) { window.scrollBy(0, window.innerHeight); return null; } return this.getNextKey(key); }
I thought of adding window.scrollBy(0, window.innerHeight); to provide vertical scroll but the useTablist story book only has the horizontal scroll so I was not sure window.scrollby was working or not, so I skipped this code

@snowystinger
Copy link
Member

getKeyBelow(key: Key) { if (this.tabDirection) { window.scrollBy(0, window.innerHeight); return null; } return this.getNextKey(key); } I thought of adding window.scrollBy(0, window.innerHeight); to provide vertical scroll but the useTablist story book only has the horizontal scroll so I was not sure window.scrollby was working or not, so I skipped this code

Better to just not preventDefault when we aren't actively handling that key and let the browser do its thing. It may not be the window which needs to scroll. It could be any ancestor.

Comment on lines 126 to 129
e.preventDefault();
// allowing default behavior for above and below key
if (!delegate.getKeyAbove || !delegate.getKeyBelow) {
e.preventDefault();
}
Copy link
Member

Choose a reason for hiding this comment

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

since this is in the if (e.altKey && e.key === 'Tab') { statement, this won't actually have the desired effect of allowing default behavior if the the delegate returns null from getKeyAbove/getKeyBelow. You'll want to look at the cases in the switch statement like here:

and make those e.preventDefault not be called if nextKey is null I imagine.

@yihuiliao
Copy link
Member

I just wanted to pop in and let you know that the team might be slow to review as we work on some other priorities. We appreciate your understanding and apologize for the wait.

@mdhmaiti
Copy link
Contributor Author

No no its okk , I also had my exams and I am still learning, I am willing to wait

@snowystinger
Copy link
Member

Update on comment #6023 (review) from above here: #5996 (comment)

@devongovett devongovett force-pushed the main branch 2 times, most recently from 8cb1a5d to 3013156 Compare July 23, 2024 22:43
Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

Verified that ArrowUp/Down still have browser default behavior when navigating a horizontally oriented TabList but ArrowUp/Down/Left/Right all still shift the Tab selection for vertical tabs. Thanks for the contribution!

@snowystinger snowystinger merged commit c4a783e into adobe:main Aug 13, 2024
29 checks passed
LFDanLu added a commit that referenced this pull request Aug 15, 2024
LFDanLu added a commit that referenced this pull request Aug 15, 2024
* Translations for TagGroup

* add number of tags

* Revert " fix/bug useTablist #5996 (#6023)"

This reverts commit c4a783e.

* Revert "Extract `ToggleStateProps` type to use only what is needed in `useToggleState` (#3836)"

This reverts commit 81e3804.

---------

Co-authored-by: Daniel Lu <dl1644@gmail.com>
reidbarber pushed a commit that referenced this pull request Aug 21, 2024
* fix/bug useTabist #5996 and added tests
reidbarber added a commit that referenced this pull request Aug 21, 2024
* Update Picker placeholder to be shorter (#6796)

* feat: Support fragments in collections (#6430)

Co-authored-by: Reid Barber <reid@reidbarber.com>
Co-authored-by: Robert Snow <rsnow@adobe.com>

* Exposing prop disabledBehavior to TableView (#6832)

* fix/bug useTablist #5996 (#6023)

* fix/bug useTabist #5996 and added tests

* Extract `ToggleStateProps` type to use only what is needed in `useToggleState` (#3836)

* Extract `ToggleStateProps` type to use only what is needed in `useToggleState`

---------

Co-authored-by: Robert Snow <rsnow@adobe.com>
Co-authored-by: solimant <solimant@users.noreply.github.com>
Co-authored-by: Kyle Taborski <ktabors@yahoo.com>
Co-authored-by: Medhashis Maiti <129734281+mdhmaiti@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@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.

"useTabList" hook keyboard navigation with arrow keys not considering orientation
5 participants