-
-
Notifications
You must be signed in to change notification settings - Fork 311
fix: add keyboard navigation support #2737
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
Open
sameersharmadev
wants to merge
7
commits into
OWASP:main
Choose a base branch
from
sameersharmadev:keyboard-navigation-fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9eeb46d
fix: add missing keyboard navigation support and accessiblity fixes
sameersharmadev 2b47659
delete local testing page
sameersharmadev 44d50d5
update action button interface to match the new structure
sameersharmadev 94468eb
apply code quality fixes
sameersharmadev 4009006
apply code quality fixes
sameersharmadev e304535
resolve merge conflicts
sameersharmadev af41a32
fix duplicate props
sameersharmadev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| 'use client'; | ||
|
|
||
| import React from 'react' | ||
| import ModuleList from 'components/ModuleList' | ||
|
|
||
| export default function DevModuleListPage() { | ||
| const lessThan5 = ['Module 1', 'Module 2', 'Module 3'] | ||
| const exactly5 = ['Module 1', 'Module 2', 'Module 3', 'Module 4', 'Module 5'] | ||
| const manyModules = Array.from({ length: 8 }, (_, i) => `Module ${i + 1}`) | ||
| const sixModules = Array.from({ length: 6 }, (_, i) => `Module ${i + 1}`) | ||
| const longModule = [ | ||
| 'This is a very long module name that exceeds fifty characters and should be truncated', | ||
| ] | ||
| const emptyStrings = ['', 'Valid Module', ''] | ||
|
|
||
| // show empty / undefined / null cases (cast to any to allow rendering in dev) | ||
| const undefinedModules = undefined as any | ||
| const nullModules = null as any | ||
| const emptyArray: string[] = [] | ||
|
|
||
| return ( | ||
| <main className="min-h-screen p-8 bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-gray-100"> | ||
| <h1 className="mb-4 text-2xl font-bold">Dev: ModuleList</h1> | ||
| <p className="mb-6 text-sm text-gray-600 dark:text-gray-400"> | ||
| Use Tab + Enter/Space to test keyboard activation and focus rings. This page renders the | ||
| same scenarios covered by the unit tests. | ||
| </p> | ||
|
|
||
| <section className="mb-8"> | ||
| <h2 className="mb-2 font-semibold">Less than 5 modules</h2> | ||
| <ModuleList modules={lessThan5} /> | ||
| </section> | ||
|
|
||
| <section className="mb-8"> | ||
| <h2 className="mb-2 font-semibold">Exactly 5 modules</h2> | ||
| <ModuleList modules={exactly5} /> | ||
| </section> | ||
|
|
||
| <section className="mb-8"> | ||
| <h2 className="mb-2 font-semibold">More than 5 modules (8 items)</h2> | ||
| <ModuleList modules={manyModules} /> | ||
| </section> | ||
|
|
||
| <section className="mb-8"> | ||
| <h2 className="mb-2 font-semibold">Edge case: exactly 6 modules</h2> | ||
| <ModuleList modules={sixModules} /> | ||
| </section> | ||
|
|
||
| <section className="mb-8"> | ||
| <h2 className="mb-2 font-semibold">Long module name (truncation)</h2> | ||
| <ModuleList modules={longModule} /> | ||
| </section> | ||
|
|
||
| <section className="mb-8"> | ||
| <h2 className="mb-2 font-semibold">Modules with empty strings</h2> | ||
| <ModuleList modules={emptyStrings} /> | ||
| </section> | ||
|
|
||
| <section className="mb-8"> | ||
| <h2 className="mb-2 font-semibold">Empty / undefined / null (should render nothing)</h2> | ||
| <div className="space-y-4"> | ||
| <div> | ||
| <div className="mb-1 text-sm text-gray-500">Empty array</div> | ||
| <ModuleList modules={emptyArray} /> | ||
| </div> | ||
| <div> | ||
| <div className="mb-1 text-sm text-gray-500">Undefined (dev cast)</div> | ||
| <ModuleList modules={undefinedModules} /> | ||
| </div> | ||
| <div> | ||
| <div className="mb-1 text-sm text-gray-500">Null (dev cast)</div> | ||
| <ModuleList modules={nullModules} /> | ||
| </div> | ||
| </div> | ||
| </section> | ||
| </main> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,9 @@ const ShowMoreButton = ({ onToggle }: { onToggle: () => void }) => { | |||||||||||
| type="button" | ||||||||||||
| disableAnimation | ||||||||||||
| onPress={handleToggle} | ||||||||||||
| className="flex items-center bg-transparent px-0 text-blue-400" | ||||||||||||
| aria-expanded={isExpanded} | ||||||||||||
| aria-label={isExpanded ? 'Show less items' : 'Show more items'} | ||||||||||||
| className="flex items-center bg-transparent px-0 text-blue-400 focus:outline-none focus-visible:ring-1 focus-visible:ring-offset-1" | ||||||||||||
|
Comment on lines
+20
to
+22
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| > | ||||||||||||
| {isExpanded ? ( | ||||||||||||
| <> | ||||||||||||
|
|
||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ const SortBy = ({ | |
| classNames={{ | ||
| label: 'font-medium text-sm text-gray-700 dark:text-gray-300 w-auto select-none pe-0', | ||
| trigger: | ||
| 'bg-transparent data-[hover=true]:bg-transparent focus:outline-none focus:ring-0 border-none shadow-none text-nowrap w-32 min-h-8 h-8 text-sm font-medium text-gray-800 dark:text-gray-200 hover:text-gray-900 dark:hover:text-gray-100 transition-all duration-0', | ||
| 'bg-transparent data-[hover=true]:bg-transparent focus:outline-none focus-visible:ring-1 focus-visible:ring-1 focus-visible:ring-offset-1 border-none shadow-none text-nowrap w-32 min-h-8 h-8 text-sm font-medium text-gray-800 dark:text-gray-200 hover:text-gray-900 dark:hover:text-gray-100 transition-all duration-0', | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| value: 'text-gray-800 dark:text-gray-200 font-medium', | ||
| selectorIcon: 'text-gray-500 dark:text-gray-400 transition-transform duration-200', | ||
| popoverContent: | ||
|
|
@@ -42,7 +42,7 @@ const SortBy = ({ | |
| <SelectItem | ||
| key={option.key} | ||
| classNames={{ | ||
| base: 'text-sm text-gray-700 dark:text-gray-300 hover:bg-transparent dark:hover:bg-transparent focus:bg-gray-100 dark:focus:bg-[#404040] focus:outline-none rounded-sm px-3 py-2 cursor-pointer transition-colors duration-150 data-[selected=true]:bg-blue-50 dark:data-[selected=true]:bg-blue-900/20 data-[selected=true]:text-blue-600 dark:data-[selected=true]:text-blue-400 data-[focus=true]:bg-gray-100 dark:data-[focus=true]:bg-[#404040]', | ||
| base:'text-sm text-gray-700 dark:text-gray-300 hover:bg-transparent dark:hover:bg-transparent focus:bg-gray-100 dark:focus:bg-[#404040] focus:outline-none rounded-sm px-3 py-2 cursor-pointer transition-colors duration-150 data-[selected=true]:bg-blue-50 dark:data-[selected=true]:bg-blue-900/20 data-[selected=true]:text-blue-600 dark:data-[selected=true]:text-blue-400 data-[focus=true]:bg-gray-100 dark:data-[focus=true]:bg-[#404040] focus:ring-1 focus-visible:ring-offset-1', | ||
| }} | ||
| > | ||
| {option.label} | ||
|
|
@@ -61,8 +61,15 @@ const SortBy = ({ | |
| closeDelay={100} | ||
| > | ||
| <button | ||
| aria-pressed={selectedOrder === 'asc'} | ||
| onClick={() => onOrderChange(selectedOrder === 'asc' ? 'desc' : 'asc')} | ||
| className="inline-flex h-9 w-9 items-center justify-center rounded-lg border border-gray-300 bg-gray-100 p-0 shadow-sm transition-all duration-200 hover:bg-gray-200 hover:shadow-md focus:ring-2 focus:ring-gray-300 focus:ring-offset-1 focus:outline-none dark:border-gray-600 dark:bg-[#323232] dark:hover:bg-[#404040] dark:focus:ring-gray-500" | ||
| onKeyDown={(e) => { | ||
| if (e.key === 'Enter' || e.key === ' ') { | ||
| e.preventDefault() | ||
| onOrderChange(selectedOrder === 'asc' ? 'desc' : 'asc') | ||
| } | ||
| }} | ||
| className="inline-flex h-9 w-9 items-center justify-center rounded-lg border border-gray-300 bg-gray-100 p-0 shadow-sm transition-all duration-200 hover:bg-gray-200 hover:shadow-md focus:outline-none focus-visible:ring-2 focus-visible:ring-gray-300 focus-visible:ring-offset-1 dark:border-gray-600 dark:bg-[#323232] dark:hover:bg-[#404040] dark:focus-visible:ring-gray-500" | ||
| aria-label={ | ||
| selectedOrder === 'asc' ? 'Sort in ascending order' : 'Sort in descending order' | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

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.
@sameersharmadev why was this added? Do we need this here? 🤔
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.
No no we don't. I forgot to check before I pushed the changes 😅