-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Cdk listbox dev app #20010
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
Cdk listbox dev app #20010
Conversation
087865d
to
71d9806
Compare
it('should focus and toggle the next item when pressing SHIFT + DOWN_ARROW', () => { | ||
let selectedOptions = optionInstances.filter(option => option.selected); | ||
const downKeyEvent = createKeyboardEvent('keydown', DOWN_ARROW); | ||
Object.defineProperty(downKeyEvent, 'shiftKey', {get: () => true}); |
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.
You should pass the modifiers directly to createKeyboardEvent
(so we avoid the defineProperty
call here).
'[attr.aria-activedescendant]': '_getAriaActiveDescendant()' | ||
} | ||
}) | ||
export class CdkListbox implements AfterContentInit, OnDestroy, OnInit { | ||
|
||
_listKeyManager: ActiveDescendantKeyManager<CdkOption>; | ||
_selectionModel: SelectionModel<CdkOption>; | ||
tabIndex = 0; |
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.
Should this be prefixed with an underscore? (similarly to how we do it within the selection list)
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.
Yeah probably to stay consistent.
@@ -0,0 +1,10 @@ | |||
<ul cdkListbox class="example-listbox" [multiple]="multiSelectable" [useActiveDescendant]="activeDescendant"> | |||
<li class="example-option" cdkOption>Apple</li> |
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.
Is this class a noop right now?
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.
Ah yes I forgot to remove it after I changed the way I did the styling.
styleUrls: ['cdk-listbox-demo.css'], | ||
}) | ||
export class CdkListboxDemo { | ||
multiSelectable = false; |
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.
Nit: This file should use 2 spaces for indentation.
We should set up a formatter at some point again: #19879
padding: 0; | ||
} | ||
|
||
.cdk-option-selected { |
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.
Could you change these styles to only target css classes prefixed with demo-
? It makes debugging the dev-app easier if you can know immediately where the styles are coming from
|
||
/** Will select an option if shift was pressed while navigating to the option */ | ||
const isArrow = (keyCode === UP_ARROW || keyCode === DOWN_ARROW); | ||
if (isArrow && event.shiftKey && previousActiveIndex !== this._listKeyManager.activeItemIndex) { |
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.
What's the thinking behind toggling options based on arrow keys with shift rather than requiring a separate space/enter keypress? Was this from the aria authoring practices?
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.
So it would work with a separate space/enter keypress. In the authoring practices it says that selection via SHIFT + arrow key is an optional way to do selection.
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.
LGTM for dev-app and build file changes. I'll leave the listbox shift selection change to others (looks reasonable to me though)
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.
LGTM
* build: Added required files to listbox directory. * build: added listbox option directive and renamed listbox directive files. * build: Added required files to listbox directory. * build: added listbox option directive and renamed listbox directive files. * build: Added required files to listbox directory. * build: added listbox option directive and renamed listbox directive files. * build: Added required files to listbox directory. * build: added listbox option directive and renamed listbox directive files. * feat(listbox): added support for non-multiple listbox and aria activedescendant. * fix(listbox): formatted BUILD.bazel. * feat(dev-app/listbox): added cdk listbox example to the dev-app. * feat(listbox): added shift key selection. * test(listbox): added test for selection via shift key. * fix(listbox): formatted dev app build file. * fix(listbox): added codeowners for dev-app listbox example. * fix(listbox): removed width css property. * fix(listbox): removed private properties from host bindings to fix view engine bugs. * nit(listbox): changed double quote to single quote. * refactor(listbox): fixed some styling errors and added modifier key to createKeyboardEvent. * nit(listbox): changed spacing. * nit(listbox): spacing.: * nit(listbox): removed extra blank line. * refactor(listbox): changed test to have a stronger check on selected. * refactor(listbox): changed css classes to use demo- prefix. (cherry picked from commit add6ad1)
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Made an example for listbox in the dev-app and added selection of options via arrow key navigation while pressing shift.