Skip to content

Commit 664b229

Browse files
committed
fix(policy-workbench): clear pointer focus after closing rules dialog
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent d0def13 commit 664b229

1 file changed

Lines changed: 36 additions & 6 deletions

File tree

src/views/Settings/PolicyWorkbench/RealPolicyWorkbench.vue

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
@pointerdown="trackPress('cards', summary.key, $event)"
5656
@mouseup="markSelectionGesture('cards', summary.key)"
5757
@click="openSettingFromPointer('cards', summary.key, $event)"
58-
@keydown.enter.prevent="state.openSetting(summary.key)"
59-
@keydown.space.prevent="state.openSetting(summary.key)">
58+
@keydown.enter.prevent="openSettingFromKeyboard(summary.key)"
59+
@keydown.space.prevent="openSettingFromKeyboard(summary.key)">
6060
<div class="policy-workbench__setting-body">
6161
<div class="policy-workbench__setting-header">
6262
<div>
@@ -85,7 +85,7 @@
8585
</div>
8686

8787
<div class="policy-workbench__setting-footer">
88-
<NcButton variant="secondary" class="policy-workbench__manage-button" :aria-label="t('libresign', 'Configure setting')" @click.stop="state.openSetting(summary.key)">
88+
<NcButton variant="secondary" class="policy-workbench__manage-button" :aria-label="t('libresign', 'Configure setting')" @click.stop="openSettingFromAction(summary.key, $event)">
8989
{{ t('libresign', 'Configure') }}
9090
</NcButton>
9191
</div>
@@ -102,8 +102,8 @@
102102
@pointerdown="trackPress('list', summary.key, $event)"
103103
@mouseup="markSelectionGesture('list', summary.key)"
104104
@click="openSettingFromPointer('list', summary.key, $event)"
105-
@keydown.enter.prevent="state.openSetting(summary.key)"
106-
@keydown.space.prevent="state.openSetting(summary.key)">
105+
@keydown.enter.prevent="openSettingFromKeyboard(summary.key)"
106+
@keydown.space.prevent="openSettingFromKeyboard(summary.key)">
107107
<div class="policy-workbench__settings-row-main">
108108
<h3 class="policy-workbench__setting-title">
109109
<span v-html="highlightText(summary.title)"></span>
@@ -123,7 +123,7 @@
123123
<span class="policy-workbench__settings-row-stat policy-workbench__settings-row-stat--count"><strong>{{ t('libresign', 'Custom rules') }}:</strong> {{ formatOverrideSummary(summary.groupCount, summary.userCount) }}</span>
124124
</div>
125125

126-
<NcButton variant="secondary" class="policy-workbench__manage-button" :aria-label="t('libresign', 'Configure setting')" @click.stop="state.openSetting(summary.key)">
126+
<NcButton variant="secondary" class="policy-workbench__manage-button" :aria-label="t('libresign', 'Configure setting')" @click.stop="openSettingFromAction(summary.key, $event)">
127127
{{ t('libresign', 'Configure') }}
128128
</NcButton>
129129
</article>
@@ -446,6 +446,7 @@ const removalFeedback = ref<string | null>(null)
446446
const removalFeedbackTimeout = ref<number | null>(null)
447447
const lastPress = ref<{ surface: 'cards' | 'list', key: string, x: number, y: number } | null>(null)
448448
const recentSelectionGesture = ref<{ surface: 'cards' | 'list', key: string, at: number } | null>(null)
449+
const clearCatalogFocusOnClose = ref(false)
449450
const openRuleActionsKey = ref<string | null>(null)
450451
const crudSearch = ref('')
451452
const crudScopeFilter = ref<'all' | 'system' | 'group' | 'user'>('all')
@@ -1006,6 +1007,17 @@ function openSettingFromPointer(surface: 'cards' | 'list', key: string, event: M
10061007
return
10071008
}
10081009
1010+
clearCatalogFocusOnClose.value = true
1011+
state.openSetting(key as never)
1012+
}
1013+
1014+
function openSettingFromAction(key: string, event: MouseEvent) {
1015+
clearCatalogFocusOnClose.value = event.detail > 0
1016+
state.openSetting(key as never)
1017+
}
1018+
1019+
function openSettingFromKeyboard(key: string) {
1020+
clearCatalogFocusOnClose.value = false
10091021
state.openSetting(key as never)
10101022
}
10111023
@@ -1158,6 +1170,15 @@ function confirmDiscardDialog() {
11581170
11591171
if (action === 'close-setting') {
11601172
state.closeSetting()
1173+
if (clearCatalogFocusOnClose.value) {
1174+
void nextTick().then(() => {
1175+
const activeElement = document.activeElement
1176+
if (activeElement instanceof HTMLElement) {
1177+
activeElement.blur()
1178+
}
1179+
})
1180+
}
1181+
clearCatalogFocusOnClose.value = false
11611182
}
11621183
11631184
openRuleActionsKey.value = null
@@ -1240,6 +1261,15 @@ function requestCloseSetting() {
12401261
}
12411262
12421263
state.closeSetting()
1264+
if (clearCatalogFocusOnClose.value) {
1265+
void nextTick().then(() => {
1266+
const activeElement = document.activeElement
1267+
if (activeElement instanceof HTMLElement) {
1268+
activeElement.blur()
1269+
}
1270+
})
1271+
}
1272+
clearCatalogFocusOnClose.value = false
12431273
}
12441274
12451275
onMounted(async () => {

0 commit comments

Comments
 (0)