Skip to content

Commit 12d13d4

Browse files
committed
fixup! docs(cdk-experimental/listbox): add docs & examples
1 parent 664f36f commit 12d13d4

File tree

4 files changed

+31
-32
lines changed

4 files changed

+31
-32
lines changed

src/cdk-experimental/listbox/listbox.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ Listboxes only support a single selected option at a time by default, but adding
7979

8080
### Listbox value
8181

82-
The listbox's value is an array containing the values of the selected option(s). The listbox's value
83-
can be bound using `[cdkListboxValue]` and `(cdkListboxValueChange)`.
82+
The listbox's value is an array containing the values of the selected option(s). This is true even
83+
for the single selection listbox, whose value is an array containing a single element. The listbox's
84+
value can be bound using `[cdkListboxValue]` and `(cdkListboxValueChange)`.
8485

8586
<!-- example({
8687
"example": "cdk-listbox-value-binding",
@@ -101,7 +102,7 @@ objects, you should provide a custom comparison function instead. This can be se
101102

102103
### Angular Forms support
103104

104-
The CDK Listbox has out of the box support for both template driven forms and reactive forms.
105+
The CDK Listbox supports both template driven forms and reactive forms.
105106

106107
<!-- example({
107108
"example": "cdk-listbox-template-forms",
@@ -134,7 +135,7 @@ validation errors:
134135

135136
### Disabling options
136137

137-
Individual options can be disabled for selection by setting `cdkOptionDisabled` on them.
138+
You can disable options for selection by setting `cdkOptionDisabled`.
138139
In addition, the entire listbox control can be disabled by setting `cdkListboxDisabled` on the
139140
listbox element.
140141

@@ -172,7 +173,7 @@ If you prefer to use the [aria-activedescendant][activedescendant] strategy inst
172173
#### Orientation
173174

174175
Listboxes assume a vertical orientation by default, but can be customized by setting the
175-
`cdkListboxOrientation` input oe listbox. Note that this only affects the keyboard navigation. You
176+
`cdkListboxOrientation` input. Note that this only affects the keyboard navigation. You
176177
will still need to adjust your CSS styles to change the visual appearance.
177178

178179
<!-- example({
@@ -197,10 +198,10 @@ setting the `cdkOptionTypeaheadLabel` on the option.
197198

198199
When using keyboard navigation to navigate through the options, the navigation wraps when attempting
199200
to navigate past the start or end of the options. To change this, set
200-
`cdkListboxNavigationWraps=false` on the listbox.
201+
`cdkListboxNavigationWrapDisabled` on the listbox.
201202

202203
Keyboard navigation skips disabled options by default. To change this set
203-
`cdkListboxNavigationSkipsDisabled=false` on the listbox.
204+
`cdkListboxNavigatesDisabledOptions` on the listbox.
204205

205206
<!-- example({
206207
"example": "cdk-listbox-custom-navigation",
@@ -211,6 +212,6 @@ Keyboard navigation skips disabled options by default. To change this set
211212
<!-- links -->
212213

213214
[aria]: https://www.w3.org/WAI/ARIA/apg/patterns/listbox/ 'WAI ARIA Listbox Pattern'
214-
[keyboard]: https://www.w3.org/WAI/ARIA/apg/patterns/listbox/#keyboard-interaction-11
215-
[roving-tabindex]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/Keyboard-navigable_JavaScript_widgets#technique_1_roving_tabindex
216-
[activedescendant]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/Keyboard-navigable_JavaScript_widgets#technique_2_aria-activedescendant
215+
[keyboard]: https://www.w3.org/WAI/ARIA/apg/patterns/listbox/#keyboard-interaction-11 'WAI ARIA Listbox Keyboard Interaction'
216+
[roving-tabindex]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/Keyboard-navigable_JavaScript_widgets#technique_1_roving_tabindex 'MDN Roving Tabindex Technique'
217+
[activedescendant]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/Keyboard-navigable_JavaScript_widgets#technique_2_aria-activedescendant 'MDN aria-activedescendant Technique'

src/cdk-experimental/listbox/listbox.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,8 @@ describe('CdkOption and CdkListbox', () => {
908908
[cdkListboxDisabled]="isListboxDisabled"
909909
[cdkListboxUseActiveDescendant]="isActiveDescendant"
910910
[cdkListboxOrientation]="orientation"
911-
[cdkListboxKeyboardNavigationWraps]="navigationWraps"
912-
[cdkListboxKeyboardNavigationSkipsDisabled]="navigationSkipsDisabled"
911+
[cdkListboxNavigationWrapDisabled]="!navigationWraps"
912+
[cdkListboxNavigatesDisabledOptions]="!navigationSkipsDisabled"
913913
(cdkListboxValueChange)="onSelectionChange($event)">
914914
<div cdkOption="apple"
915915
[cdkOptionDisabled]="isAppleDisabled"

src/cdk-experimental/listbox/listbox.ts

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -358,28 +358,28 @@ export class CdkListbox<T = unknown>
358358
* Whether the keyboard navigation should wrap when the user presses arrow down on the last item
359359
* or arrow up on the first item.
360360
*/
361-
@Input('cdkListboxKeyboardNavigationWraps')
362-
get keyboardNavigationWraps() {
363-
return this._keyboardNavigationWraps;
361+
@Input('cdkListboxNavigationWrapDisabled')
362+
get navigationWrapDisabled() {
363+
return this._navigationWrapDisabled;
364364
}
365-
set keyboardNavigationWraps(wrap: BooleanInput) {
366-
this._keyboardNavigationWraps = coerceBooleanProperty(wrap);
367-
this.listKeyManager?.withWrap(this._keyboardNavigationWraps);
365+
set navigationWrapDisabled(wrap: BooleanInput) {
366+
this._navigationWrapDisabled = coerceBooleanProperty(wrap);
367+
this.listKeyManager?.withWrap(!this._navigationWrapDisabled);
368368
}
369-
private _keyboardNavigationWraps = true;
369+
private _navigationWrapDisabled = false;
370370

371371
/** Whether keyboard navigation should skip over disabled items. */
372-
@Input('cdkListboxKeyboardNavigationSkipsDisabled')
373-
get keyboardNavigationSkipsDisabled() {
374-
return this._keyboardNavigationSkipsDisabled;
372+
@Input('cdkListboxNavigatesDisabledOptions')
373+
get navigateDisabledOptions() {
374+
return this._navigateDisabledOptions;
375375
}
376-
set keyboardNavigationSkipsDisabled(skip: BooleanInput) {
377-
this._keyboardNavigationSkipsDisabled = coerceBooleanProperty(skip);
376+
set navigateDisabledOptions(skip: BooleanInput) {
377+
this._navigateDisabledOptions = coerceBooleanProperty(skip);
378378
this.listKeyManager?.skipPredicate(
379-
this._keyboardNavigationSkipsDisabled ? this._skipDisabledPredicate : this._skipNonePredicate,
379+
this._navigateDisabledOptions ? this._skipNonePredicate : this._skipDisabledPredicate,
380380
);
381381
}
382-
private _keyboardNavigationSkipsDisabled = true;
382+
private _navigateDisabledOptions = false;
383383

384384
/** Emits when the selected value(s) in the listbox change. */
385385
@Output('cdkListboxValueChange') readonly valueChange = new Subject<ListboxValueChangeEvent<T>>();
@@ -860,14 +860,12 @@ export class CdkListbox<T = unknown>
860860
/** Initialize the key manager. */
861861
private _initKeyManager() {
862862
this.listKeyManager = new ActiveDescendantKeyManager(this.options)
863-
.withWrap(this._keyboardNavigationWraps)
863+
.withWrap(!this._navigationWrapDisabled)
864864
.withTypeAhead()
865865
.withHomeAndEnd()
866866
.withAllowedModifierKeys(['shiftKey'])
867867
.skipPredicate(
868-
this._keyboardNavigationSkipsDisabled
869-
? this._skipDisabledPredicate
870-
: this._skipNonePredicate,
868+
this._navigateDisabledOptions ? this._skipNonePredicate : this._skipDisabledPredicate,
871869
);
872870

873871
if (this.orientation === 'vertical') {

src/components-examples/cdk-experimental/listbox/cdk-listbox-custom-navigation/cdk-listbox-custom-navigation-example.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
Flavor
55
</label>
66
<ul cdkListbox
7-
cdkListboxKeyboardNavigationSkipsDisabled="false"
8-
cdkListboxKeyboardNavigationWraps="false"
7+
cdkListboxNavigatesDisabledOptions
8+
cdkListboxNavigationWrapDisabled
99
aria-labelledby="example-flavor-label"
1010
class="example-listbox">
1111
<li cdkOption="chocolate"

0 commit comments

Comments
 (0)