Skip to content

Commit

Permalink
fix: Fix tab focus when other elements are displayed next to text tha…
Browse files Browse the repository at this point in the history
…t are within a focus trap

Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Jan 19, 2024
1 parent 2c30edb commit 5dbd121
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
17 changes: 10 additions & 7 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -637,16 +637,10 @@ export default {
onFocus() {
this.emit('focus')
// Make sure that the focus trap doesn't catch tab keys while being in the contenteditable
window._nc_focus_trap?.[0]?.pause()
},
onBlur() {
this.emit('blur')
// Hand back focus to the previous trap
window._nc_focus_trap?.[0]?.unpause()
this.$el.focus()
},
onAddImageNode() {
Expand Down Expand Up @@ -744,6 +738,15 @@ export default {
this.$editor.commands.insertContent('\t')
this.$editor.commands.focus()
event.preventDefault()
event.stopPropagation()
return
}
if (event.key === 'Tab') {
const possibleEditorTabCommand = this.$editor.can().sinkListItem() || this.$editor.can().liftListItem() || this.$editor.can().goToNextCell() || this.$editor.can().goToPreviousCell()
if (possibleEditorTabCommand) {
event.stopPropagation()
}
return
}
Expand Down
3 changes: 1 addition & 2 deletions src/components/Editor/ContentContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
<EditorOutline />
</div>
<slot />
<EditorContent tabindex="0"
role="document"
<EditorContent role="document"
class="editor__content text-editor__content"
:editor="$editor" />
<div class="text-editor__content-wrapper__right" />
Expand Down

0 comments on commit 5dbd121

Please sign in to comment.