Skip to content

Commit

Permalink
fix(list, list-item): support keyboard sorting in screen readers. #7426
Browse files Browse the repository at this point in the history
  • Loading branch information
driskull committed Apr 2, 2024
1 parent 1563dcb commit 2cbf451
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions packages/calcite-components/src/components/handle/handle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Event,
EventEmitter,
h,
Host,
Method,
Prop,
State,
Expand Down Expand Up @@ -298,24 +299,26 @@ export class Handle implements LoadableComponent, T9nComponent, InteractiveCompo

render(): VNode {
return (
// Needs to be a span because of https://github.com/SortableJS/Sortable/issues/1486
<span
aria-disabled={this.disabled ? toAriaBoolean(this.disabled) : null}
aria-label={this.disabled ? null : this.getAriaText("label")}
aria-pressed={this.disabled ? null : toAriaBoolean(this.selected)}
class={{ [CSS.handle]: true, [CSS.handleSelected]: !this.disabled && this.selected }}
onBlur={this.handleBlur}
onKeyDown={this.handleKeyDown}
role="button"
tabIndex={this.disabled ? null : 0}
title={this.getTooltip()}
// eslint-disable-next-line react/jsx-sort-props -- ref should be last so node attrs/props are in sync (see https://github.com/Esri/calcite-design-system/pull/6530)
ref={(el): void => {
this.handleButton = el;
}}
>
<calcite-icon icon={ICONS.drag} scale="s" />
</span>
<Host role="application">
<span
// Needs to be a span because of https://github.com/SortableJS/Sortable/issues/1486
aria-disabled={this.disabled ? toAriaBoolean(this.disabled) : null}
aria-label={this.disabled ? null : this.getAriaText("label")}
aria-pressed={this.disabled ? null : toAriaBoolean(this.selected)}
class={{ [CSS.handle]: true, [CSS.handleSelected]: !this.disabled && this.selected }}
onBlur={this.handleBlur}
onKeyDown={this.handleKeyDown}
role="button"
tabIndex={this.disabled ? null : 0}
title={this.getTooltip()}
// eslint-disable-next-line react/jsx-sort-props -- ref should be last so node attrs/props are in sync (see https://github.com/Esri/calcite-design-system/pull/6530)
ref={(el): void => {
this.handleButton = el;
}}
>
<calcite-icon icon={ICONS.drag} scale="s" />
</span>
</Host>
);
}
}

0 comments on commit 2cbf451

Please sign in to comment.