Skip to content

Commit

Permalink
fix(user_status): Fix losing focus to body when closing user status m…
Browse files Browse the repository at this point in the history
…odal

Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal committed Feb 1, 2024
1 parent 937a6a8 commit a6fac21
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/user_status/src/UserStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
</NcButton>

<!-- Status management modal -->
<SetStatusModal v-if="isModalOpen" @close="closeModal" />
<SetStatusModal v-if="isModalOpen"
:inline="inline"
@close="closeModal" />
</component>
</template>

Expand Down
20 changes: 20 additions & 0 deletions apps/user_status/src/components/SetStatusModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<template>
<NcModal size="normal"
:name="$t('user_status', 'Set status')"
:set-return-focus="setReturnFocus"
@close="closeModal">
<div class="set-status-modal">
<!-- Status selector -->
Expand Down Expand Up @@ -108,6 +109,18 @@ export default {
},
mixins: [OnlineStatusMixin],

props: {
/**
* Whether the component should be rendered as a Dashboard Status or a User Menu Entries
* true = Dashboard Status
* false = User Menu Entries
*/
inline: {
type: Boolean,
default: false,
},
},

data() {
return {
clearAt: null,
Expand Down Expand Up @@ -156,6 +169,13 @@ export default {

return this.$t('user_status', 'Reset status')
},

setReturnFocus() {
if (this.inline) {
return undefined
}
return document.querySelector('[aria-controls="header-menu-user-menu"]') ?? undefined
},
},

watch: {
Expand Down

0 comments on commit a6fac21

Please sign in to comment.