Skip to content

Commit

Permalink
Don't add aria-autocomplete when there are no completion sources
Browse files Browse the repository at this point in the history
FIX: Avoid adding an `aria-autocomplete` attribute to the editor when there
are no active sources active.

See https://discuss.codemirror.net/t/avoiding-aria-autocomplete-list-when-no-autocompletion-providers/8313
  • Loading branch information
marijnh committed Jun 14, 2024
1 parent 099b9fe commit 3f6e41d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class CompletionState {

get tooltip(): Tooltip | null { return this.open ? this.open.tooltip : null }

get attrs() { return this.open ? this.open.attrs : baseAttrs }
get attrs() { return this.open ? this.open.attrs : this.active.length ? baseAttrs : noAttrs }
}

function sameResults(a: readonly ActiveSource[], b: readonly ActiveSource[]) {
Expand All @@ -172,6 +172,8 @@ const baseAttrs = {
"aria-autocomplete": "list"
}

const noAttrs = {}

function makeAttrs(id: string, selected: number) {
let result: {[name: string]: string} = {
"aria-autocomplete": "list",
Expand Down

0 comments on commit 3f6e41d

Please sign in to comment.