Repository navigation
List: set aria-setsize and aria-posinset - #29019
Conversation
| this.eventBufferer.bufferEvents(() => this.spliceable.splice(start, deleteCount, elements)); | ||
| this.eventBufferer.bufferEvents(() => { | ||
| this.spliceable.splice(start, deleteCount, elements); | ||
| this.view.domNode.setAttribute('aria-setsize', this.length.toString()); |
There was a problem hiding this comment.
You should do this outside the event buffering.
Shouldn't there be an initial value for this, before any splice is called?
There was a problem hiding this comment.
Initial value is 0 and I can set it in the constructor.
Ok so I will do it in the method ouside of the buffer
| setFocus(indexes: number[]): void { | ||
| indexes = indexes.sort(numericSort); | ||
| this.focus.set(indexes); | ||
| this.view.domNode.setAttribute('aria-posinset', indexes.length ? (indexes[0] + 1).toString() : undefined); |
There was a problem hiding this comment.
The w3 docs state:
Authors MUST set the value for aria-posinset to an integer greater than or equal to 1, and less than or equal to the size of the set.
Setting it to undefined doesn't sound like it's the right thing to do here.
There was a problem hiding this comment.
In that case I will jost not set it but remove the attribute, I believe that is the right thing to do
João Moreno (joaomoreno)
left a comment
There was a problem hiding this comment.
Looks good, you can merge after last changes.
| if (options.ariaLabel) { | ||
| this.view.domNode.setAttribute('aria-label', options.ariaLabel); | ||
| } | ||
| this.view.domNode.setAttribute('aria-setsize', this.length.toString()); |
There was a problem hiding this comment.
Just make this 0, to be explicit.
|
|
||
| splice(start: number, deleteCount: number, elements: T[] = []): void { | ||
| this.eventBufferer.bufferEvents(() => this.spliceable.splice(start, deleteCount, elements)); | ||
| this.eventBufferer.bufferEvents(() => { |
There was a problem hiding this comment.
Return this to the old syntax.
|
Nice! Thank you Isidor Nikolic (@isidorn) João Moreno (@joaomoreno) ! |
Fixes #27900 for the list widget
Please note: that the
spliceseems to be called even when the focus changes in the list so I might be calling setaria-setsizea bit too often.Also note that
aria-posinsetshould start with 1, not 0 thus I am doing +1. More details: https://www.w3.org/TR/wai-aria/states_and_properties#aria-posinsetJoão Moreno (@joaomoreno) once you approve on this I can do a similar thing for the tree
alexandrudima fyi