-
Notifications
You must be signed in to change notification settings - Fork 64
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
1609 - Do not set first item as active by default #1724
1609 - Do not set first item as active by default #1724
Conversation
This pull request is being automatically deployed with Vercel (learn more). widget-test-docs – ./🔍 Inspect: https://vercel.com/dojo/widget-test-docs/4SjVuYk1R7iSjwFuMFiw2PtYnFrL dojo.widgets – ./🔍 Inspect: https://vercel.com/dojo/dojo.widgets/9LjGM31nXubbGdfGF7PMpfsYMaKh |
Codecov Report
@@ Coverage Diff @@
## master #1724 +/- ##
==========================================
+ Coverage 90.24% 90.35% +0.10%
==========================================
Files 94 94
Lines 5116 5120 +4
Branches 1392 1398 +6
==========================================
+ Hits 4617 4626 +9
+ Misses 244 243 -1
+ Partials 255 251 -4
Continue to review full report at Codecov.
|
…-item-selection-behavior
src/list/index.tsx
Outdated
const first = items.slice(0, computedActiveIndex); | ||
const second = items.slice(computedActiveIndex); | ||
let foundIndex = computedActiveIndex; | ||
const first = computedActiveIndex ? items.slice(0, computedActiveIndex) : []; |
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.
if computed active index was 0
wouldn't this be falsey rather than selecting the first item?
@@ -807,7 +805,11 @@ export const List = factory(function List({ | |||
styles={rootStyles} | |||
role={menu ? 'menu' : 'listbox'} | |||
aria-orientation="vertical" | |||
aria-activedescendant={`${idBase}-item-${computedActiveIndex}`} | |||
aria-activedescendant={ | |||
computedActiveIndex !== undefined |
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.
👍 good catch
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.
couple small comments
src/list/index.tsx
Outdated
@@ -362,15 +362,21 @@ export const List = factory(function List({ | |||
if (event.metaKey || event.ctrlKey) { | |||
setActiveIndex(total - 1); | |||
} else { | |||
setActiveIndex((computedActiveIndex + 1) % total); | |||
setActiveIndex( | |||
(computedActiveIndex !== undefined ? computedActiveIndex + 1 : 0) % total |
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.
Can we do this outside the function call? It's a bit messy to understand at the moment.
src/list/index.tsx
Outdated
} | ||
break; | ||
case Keys.Up: | ||
event.preventDefault(); | ||
if (event.metaKey || event.ctrlKey) { | ||
setActiveIndex(0); | ||
} else { | ||
setActiveIndex((computedActiveIndex - 1 + total) % total); | ||
setActiveIndex( | ||
(computedActiveIndex !== undefined |
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.
Same comment re moving the logic out from the function call.
…-item-selection-behavior
Type: bug
The following has been addressed in the PR:
.dojorc
theme.variant()
is added to the root domnodetheme.compose
like thisDescription: When no active index is set, no list item is selected instead of the previous behavior of defaulting to the first item.
Resolves #1609