Skip to content

Commit

Permalink
Merge pull request #7548 from nextcloud/bugfix/7533/add-aria-labels-o…
Browse files Browse the repository at this point in the history
…n-removing-input-buttons

Add aria labels to "Remove input" buttons
  • Loading branch information
marcoambrosini authored Jul 11, 2022
2 parents 7e7db28 + cc29faf commit b3d44a8
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@
type="text"
:placeholder="t('spreed', 'Search participants')"
@input="handleInput">
<Button v-if="isSearching"
class="abort-search"
type="tertiary-no-background"
:aria-label="cancelSearchLabel"
@click="abortSearch">
<template #icon>
<Close decorative
title=""
:size="20" />
</template>
</Button>
<transition-group v-if="hasSelectedParticipants"
name="zoom"
tag="div"
Expand All @@ -50,6 +61,8 @@
</template>

<script>
import Button from '@nextcloud/vue/dist/Components/Button'
import Close from 'vue-material-design-icons/Close.vue'
import CancelableRequest from '../../../../utils/cancelableRequest.js'
import debounce from 'debounce'
import { showError } from '@nextcloud/dialogs'
Expand All @@ -60,6 +73,8 @@ import ContactSelectionBubble from './ContactSelectionBubble/ContactSelectionBub
export default {
name: 'SetContacts',
components: {
Button,
Close,
ParticipantSearchResults,
ContactSelectionBubble,
},
Expand Down Expand Up @@ -99,6 +114,14 @@ export default {
displaySearchHint() {
return !this.contactsLoading && this.searchText === ''
},
isSearching() {
return this.searchText !== ''
},
cancelSearchLabel() {
return t('spreed', 'Cancel search')
},
},
async mounted() {
Expand All @@ -123,6 +146,14 @@ export default {
this.debounceFetchSearchResults()
},
abortSearch() {
this.noResults = false
this.contactsLoading = false
this.searchResults = []
this.searchText = ''
this.focusInput()
},
debounceFetchSearchResults: debounce(function() {
this.fetchSearchResults()
}, 250),
Expand Down Expand Up @@ -183,6 +214,12 @@ export default {
margin-top: 20px;
text-align: center;
}
.abort-search {
position: absolute;
right: 0;
top: -2px;
z-index: 2;
}
}
.selected-participants {
Expand Down
30 changes: 23 additions & 7 deletions src/components/LeftSidebar/SearchBox/SearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,31 @@
type="text"
:placeHolder="placeholderText"
@keypress.enter.prevent="handleSubmit">
<button v-if="isSearching"
class="abort-search icon-close"
@click.prevent="abortSearch" />
<Button v-if="isSearching"
class="abort-search"
type="tertiary-no-background"
:aria-label="cancelSearchLabel"
@click="abortSearch">
<template #icon>
<Close decorative
title=""
:size="20" />
</template>
</Button>
</form>
</template>

<script>
import Button from '@nextcloud/vue/dist/Components/Button'
import Close from 'vue-material-design-icons/Close.vue'
import { EventBus } from '../../../services/EventBus.js'
export default {
name: 'SearchBox',
components: {
Button,
Close,
},
props: {
/**
* The placeholder for the input field
Expand Down Expand Up @@ -68,6 +82,11 @@ export default {
localValue: '',
}
},
computed: {
cancelSearchLabel() {
return t('spreed', 'Cancel search')
},
},
watch: {
localValue(localValue) {
this.$emit('update:value', localValue)
Expand Down Expand Up @@ -136,10 +155,7 @@ export default {
}
.abort-search {
margin-left: -34px;
z-index: 1;
border: none;
background-color: transparent
margin-left: -44px;
}
</style>

0 comments on commit b3d44a8

Please sign in to comment.