diff --git a/src/routes/_components/compose/ComposeAutosuggest.html b/src/routes/_components/compose/ComposeAutosuggest.html index 84836d61..c1c2d964 100644 --- a/src/routes/_components/compose/ComposeAutosuggest.html +++ b/src/routes/_components/compose/ComposeAutosuggest.html @@ -1,6 +1,4 @@ -
+
{#each items as item, i (item.shortcode || item.id || item.name)} -
  • ( get($autosuggestData_composeFocused, [$currentInstance, realm], false) ), - /* eslint-enable camelcase */ - autosuggestShownForThisInput: ({ realm, $autosuggestShown, composeFocused }) => ( + + autosuggestShownForThisInput: ({ $autosuggestShown, composeFocused }) => ( !!($autosuggestShown && composeFocused) + ), + autosuggestSelected: ({ $autosuggestData_autosuggestSelected, $currentInstance, realm }) => ( + get($autosuggestData_autosuggestSelected, [$currentInstance, realm], 0) + ), + activeDescendant: ({ autosuggestSelected, autosuggestShownForThisInput, realm }) => ( + autosuggestShownForThisInput ? `compose-autosuggest-active-item-${realm}-${autosuggestSelected}` : undefined ) + /* eslint-enable camelcase */ }, events: { selectionChange diff --git a/src/routes/_utils/createAutosuggestAccessibleLabel.js b/src/routes/_utils/createAutosuggestAccessibleLabel.js index 76686c86..06ae133d 100644 --- a/src/routes/_utils/createAutosuggestAccessibleLabel.js +++ b/src/routes/_utils/createAutosuggestAccessibleLabel.js @@ -17,6 +17,5 @@ export function createAutosuggestAccessibleLabel ( : displayName label = `${displayName} @${selected.acct}` } - return `${label} (${selectedIndex + 1} of ${searchResults.length}). ` + - 'Press up and down arrows to review and enter to select.' + return label } diff --git a/tests/spec/018-compose-autosuggest.js b/tests/spec/018-compose-autosuggest.js index a5abfc55..b705bba3 100644 --- a/tests/spec/018-compose-autosuggest.js +++ b/tests/spec/018-compose-autosuggest.js @@ -110,7 +110,7 @@ test('autosuggest only shows for one input', async t => { .selectText(getNthComposeReplyInput(1)) .pressKey('delete') .typeText(getNthComposeReplyInput(1), 'uu') - .expect($('.compose-autosuggest.shown').exists).notOk() + .expect($('.compose-autosuggest').visible).notOk() }) test('autosuggest only shows for one input part 2', async t => { @@ -118,7 +118,7 @@ test('autosuggest only shows for one input part 2', async t => { await t .hover(composeInput) .typeText(composeInput, '@adm') - .expect($('.compose-autosuggest.shown').exists).ok({ timeout }) + .expect($('.compose-autosuggest').visible).ok({ timeout }) .expect(getNthAutosuggestionResult(1).innerText).contains('@admin') .hover(getNthStatus(1)) .click(getNthReplyButton(1)) @@ -127,7 +127,7 @@ test('autosuggest only shows for one input part 2', async t => { .typeText(getNthComposeReplyInput(1), '@dd') await sleep(1000) await t.pressKey('backspace') - .expect($('.compose-autosuggest.shown').exists).notOk() + .expect($('.compose-autosuggest').visible).notOk() }) test('autocomplete disappears on blur', async t => { @@ -135,7 +135,7 @@ test('autocomplete disappears on blur', async t => { await t .hover(composeInput) .typeText(composeInput, '@adm') - .expect($('.compose-autosuggest.shown').exists).ok({ timeout }) + .expect($('.compose-autosuggest').visible).ok({ timeout }) .click(composeLengthIndicator) - .expect($('.compose-autosuggest.shown').exists).notOk() + .expect($('.compose-autosuggest').visible).notOk() })