fix: fix autocomplete in voiceover+safari (#1632)

* fix: fix autocomplete in voiceover+safari

fixes #1629

* fix test

* fix test
This commit is contained in:
Nolan Lawson 2019-11-09 23:01:32 -05:00 committed by GitHub
parent 07facea505
commit 63c9f8dc32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -8,9 +8,11 @@
class="compose-autosuggest-list-item {i === selected ? 'selected' : ''}"
role="option"
aria-selected="{i === selected}"
aria-label="{ariaLabels[i]}"
on:click="onClick(event, item)"
>
<!-- aria-label would be simpler than an sr-only element, but that breaks VoiceOver+Safari
https://github.com/nolanlawson/pinafore/issues/1629 -->
<span class="sr-only">{ariaLabels[i]}</span>
<div class="compose-autosuggest-list-grid" aria-hidden="true">
{#if type === 'account'}
<div class="compose-autosuggest-list-item-avatar">

View File

@ -22,7 +22,7 @@ test('autosuggests user handles', async t => {
await sleep(1000)
await t
.typeText(composeInput, 'hey @qu')
.expect(getNthAutosuggestionResult(1).getAttribute('aria-label')).contains('@quux')
.expect(getNthAutosuggestionResult(1).find('.sr-only').innerText).contains('@quux')
.click(getNthAutosuggestionResult(1), { timeout })
.expect(composeInput.value).eql('hey @quux ')
.typeText(composeInput, 'and also @adm')
@ -46,7 +46,7 @@ test('autosuggests custom emoji', async t => {
.click(getNthAutosuggestionResult(1))
.expect(composeInput.value).eql(':blobnom: ')
.typeText(composeInput, 'and :blob')
.expect(getNthAutosuggestionResult(1).getAttribute('aria-label')).contains('blobnom')
.expect(getNthAutosuggestionResult(1).find('.sr-only').innerText).contains('blobnom')
.expect(getNthAutosuggestionResult(1).innerText).contains(':blobnom:', { timeout })
.expect(getNthAutosuggestionResult(2).innerText).contains(':blobpats:')
.expect(getNthAutosuggestionResult(3).innerText).contains(':blobpeek:')

View File

@ -20,8 +20,8 @@ test('autosuggests hashtags', async t => {
.typeText(composeInput, 'hey #bl')
.expect(getNthAutosuggestionResult(1).innerText).contains('blank', { timeout })
.expect(getNthAutosuggestionResult(2).innerText).contains('blanka', { timeout })
.expect(getNthAutosuggestionResult(1).getAttribute('aria-label')).contains('#blank', { timeout })
.expect(getNthAutosuggestionResult(2).getAttribute('aria-label')).contains('#blanka', { timeout })
.expect(getNthAutosuggestionResult(1).find('.sr-only').innerText).contains('#blank', { timeout })
.expect(getNthAutosuggestionResult(2).find('.sr-only').innerText).contains('#blanka', { timeout })
.click(getNthAutosuggestionResult(1), { timeout })
.expect(composeInput.value).eql('hey #blank ')
.typeText(composeInput, 'and also #BL')