Skip to content

Commit 9d9065e

Browse files
Vinicius Reisvinicius73
authored andcommitted
🚸 (#2381): show menubar when user use tab key to navigate
Signed-off-by: Vinicius Reis <[email protected]>
1 parent 3399bf9 commit 9d9065e

1 file changed

Lines changed: 39 additions & 5 deletions

File tree

‎src/views/RichWorkspace.vue‎

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
:share-token="shareToken"
4242
:mime="file.mimetype"
4343
:autofocus="autofocus"
44+
:autohide="autohide"
4445
active
45-
autohide
4646
rich-workspace
4747
@ready="ready=true"
48-
@focus="focus=true"
49-
@blur="unfocus"
48+
@focus="onFocus"
49+
@blur="onBlur"
5050
@error="reset" />
5151
</div>
5252
</template>
@@ -78,6 +78,7 @@ export default {
7878
loaded: false,
7979
ready: false,
8080
autofocus: false,
81+
autohide: true,
8182
darkTheme: OCA.Accessibility && OCA.Accessibility.theme === 'dark',
8283
enabled: OCA.Text.RichWorkspaceEnabled,
8384
}
@@ -109,14 +110,23 @@ export default {
109110
}
110111
subscribe('Text::showRichWorkspace', this.showRichWorkspace)
111112
subscribe('Text::hideRichWorkspace', this.hideRichWorkspace)
113+
114+
this.listenKeydownEvents()
115+
112116
},
113117
beforeDestroy() {
114118
unsubscribe('Text::showRichWorkspace', this.showRichWorkspace)
115119
unsubscribe('Text::hideRichWorkspace', this.hideRichWorkspace)
120+
121+
this.unlistenKeydownEvents()
116122
},
117123
methods: {
118-
unfocus() {
119-
// setTimeout(() => this.focus = false, 2000)
124+
onBlur() {
125+
this.listenKeydownEvents()
126+
},
127+
onFocus() {
128+
this.focus = true
129+
this.unlistenKeydownEvents()
120130
},
121131
reset() {
122132
this.file = null
@@ -185,6 +195,30 @@ export default {
185195
hideRichWorkspace() {
186196
this.enabled = false
187197
},
198+
listenKeydownEvents() {
199+
window.addEventListener('keydown', this.onKeydown)
200+
},
201+
unlistenKeydownEvents() {
202+
clearInterval(this.$_timeoutAutohide)
203+
204+
window.removeEventListener('keydown', this.onKeydown)
205+
},
206+
onTimeoutAutohide() {
207+
this.autohide = true
208+
},
209+
onKeydown(e) {
210+
if (e.key !== 'Tab') {
211+
return
212+
}
213+
214+
// remove previous timeout
215+
clearInterval(this.$_timeoutAutohide)
216+
217+
this.autohide = false
218+
219+
// schedule to normal behaviour
220+
this.$_timeoutAutohide = setTimeout(this.onTimeoutAutohide, 7000) // 7s
221+
},
188222
},
189223
}
190224
</script>

0 commit comments

Comments
 (0)