Fix page and arrow keys not working correctly
This commit is contained in:
parent
f0b0c53536
commit
408eb75a88
@ -4,6 +4,10 @@
|
|||||||
id="context-menu-container"
|
id="context-menu-container"
|
||||||
@click="containerClick"
|
@click="containerClick"
|
||||||
@contextmenu.prevent="containerClick"
|
@contextmenu.prevent="containerClick"
|
||||||
|
@keydown.exact.up.prevent="navigateMenu(-1)"
|
||||||
|
@keydown.exact.down.prevent="navigateMenu(1)"
|
||||||
|
@keydown.exact.tab.prevent="navigateMenu(1)"
|
||||||
|
@keydown.shift.tab.prevent="navigateMenu(-1)"
|
||||||
>
|
>
|
||||||
<ul
|
<ul
|
||||||
id="context-menu"
|
id="context-menu"
|
||||||
@ -60,7 +64,6 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
Mousetrap.bind("esc", this.close);
|
Mousetrap.bind("esc", this.close);
|
||||||
Mousetrap.bind(["up", "down", "tab", "shift+tab"], this.navigateMenu);
|
|
||||||
|
|
||||||
this.$root.$on("contextmenu:user", this.openUserContextMenu);
|
this.$root.$on("contextmenu:user", this.openUserContextMenu);
|
||||||
this.$root.$on("contextmenu:channel", this.openChannelContextMenu);
|
this.$root.$on("contextmenu:channel", this.openChannelContextMenu);
|
||||||
@ -68,11 +71,12 @@ export default {
|
|||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
Mousetrap.unbind("esc", this.close);
|
Mousetrap.unbind("esc", this.close);
|
||||||
Mousetrap.unbind(["up", "down", "tab", "shift+tab"], this.navigateMenu);
|
|
||||||
|
|
||||||
this.$root.$off("contextmenu:user", this.openUserContextMenu);
|
this.$root.$off("contextmenu:user", this.openUserContextMenu);
|
||||||
this.$root.$off("contextmenu:channel", this.openChannelContextMenu);
|
this.$root.$off("contextmenu:channel", this.openChannelContextMenu);
|
||||||
this.$root.$off("contextmenu:removenetwork", this.openRemoveNetworkContextMenu);
|
this.$root.$off("contextmenu:removenetwork", this.openRemoveNetworkContextMenu);
|
||||||
|
|
||||||
|
this.close();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
openRemoveNetworkContextMenu(data) {
|
openRemoveNetworkContextMenu(data) {
|
||||||
@ -140,11 +144,7 @@ export default {
|
|||||||
this.clickItem(this.items[this.activeItem]);
|
this.clickItem(this.items[this.activeItem]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
navigateMenu(event, key) {
|
navigateMenu(direction) {
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
const direction = key === "down" || key === "tab" ? 1 : -1;
|
|
||||||
|
|
||||||
let currentIndex = this.activeItem;
|
let currentIndex = this.activeItem;
|
||||||
|
|
||||||
currentIndex += direction;
|
currentIndex += direction;
|
||||||
|
@ -154,7 +154,7 @@ document.addEventListener("keydown", (e) => {
|
|||||||
|
|
||||||
// Redirect pagedown/pageup keys to messages container so it scrolls
|
// Redirect pagedown/pageup keys to messages container so it scrolls
|
||||||
if (e.which === 33 || e.which === 34) {
|
if (e.which === 33 || e.which === 34) {
|
||||||
const chat = document.querySelector("#windows .chat-content .chat");
|
const chat = document.querySelector(".window .chat-content .chat");
|
||||||
|
|
||||||
if (chat) {
|
if (chat) {
|
||||||
chat.focus();
|
chat.focus();
|
||||||
|
Loading…
Reference in New Issue
Block a user