Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Fix initial focus trap #2001

Merged
merged 2 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/bugfix-modal-initial-focus
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Initial focus in OcModal

We've fixed a bug that was introduced in the last version, where the initial focus element provided via the focusTrapInitial property was broken.

https://github.com/owncloud/owncloud-design-system/pull/2001
13 changes: 9 additions & 4 deletions src/components/organisms/OcModal/OcModal.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="oc-modal-background" aria-labelledby="oc-modal-title">
<focus-trap :active="true" :initial-focus="getInitialFocusRef">
<focus-trap :active="true" :initial-focus="initialFocusRef">
<div
ref="ocModal"
:class="classes"
Expand Down Expand Up @@ -246,6 +246,14 @@ export default {
}
},
computed: {
initialFocusRef() {
if (this.focusTrapInitial) {
return this.focusTrapInitial
}
return () => {
return this.$refs.ocModalInput || this.$refs.ocModal
}
},
classes() {
return ["oc-modal", `oc-modal-${this.variation}`]
},
Expand Down Expand Up @@ -285,9 +293,6 @@ export default {
inputAssignPropAsValue(value) {
this.userInputValue = value
},
getInitialFocusRef() {
return this.focusTrapInitial || this.$refs.ocModalInput || this.$refs.ocModal
},
},
}
</script>
Expand Down