Describe the bug
The plugin toggles channel visibility when pressing Ctrl+Backspace (commonly used to delete words while editing longer messages), even though the default and only documented keybind is Ctrl+H. This appears to affect any key combination that shares the Ctrl modifier.
Expected behavior
The channel list should only toggle when pressing the actual configured keybind (Ctrl+H by default), not other key combinations that happen to share the same modifier key.
To reproduce
- Install plugin with default keybind (Ctrl+H)
- Start typing a message in Discord
- Press Ctrl+Backspace to delete a word
- Channel list unexpectedly toggles
Screenshots
No response
OS version
Windows 11
Discord version
Stable
BetterDiscord version
1.12.1
Plugin version
2.2.14
Additional context
Suspected cause
I suspect the keyup event handler (lines 251-261) checks whether all keybind keys are pressed without verifying the released key is actually part of the keybind. If I'm right, the condition triggers whenever Ctrl is held and any key is released, rather than only when releasing a key that's part of the configured keybind combination.
Possible fix
Adding a check to verify the released key is part of the keybind before evaluating the toggle condition might resolve this. Maybe something like:
//Keyup event
useListener("keyup", e => {
//Check if this is the last key of our keybind being released
//AND all other keybind keys are still pressed
const releasedKey = e.key.toLowerCase();
const isKeybindKey = this.keybind.some(key => key.toLowerCase() === releasedKey);
if (isKeybindKey &&
this.keybind.every(key => this.currentlyPressed[key.toLowerCase()] === true)) {
//Toggle the sidebar and rerender on toggle; change the state
setHidden(toggleSidebar(sidebarNode));
}
//Current key goes up, so clear it
this.currentlyPressed[releasedKey] = false;
//Account for bubbling
}, true);
On initial testing this seems to have fixed it for me, but of course I may have overlooked something important, so don't take it too seriously.
Describe the bug
The plugin toggles channel visibility when pressing Ctrl+Backspace (commonly used to delete words while editing longer messages), even though the default and only documented keybind is Ctrl+H. This appears to affect any key combination that shares the Ctrl modifier.
Expected behavior
The channel list should only toggle when pressing the actual configured keybind (Ctrl+H by default), not other key combinations that happen to share the same modifier key.
To reproduce
Screenshots
No response
OS version
Windows 11
Discord version
Stable
BetterDiscord version
1.12.1
Plugin version
2.2.14
Additional context
Suspected cause
I suspect the keyup event handler (lines 251-261) checks whether all keybind keys are pressed without verifying the released key is actually part of the keybind. If I'm right, the condition triggers whenever Ctrl is held and any key is released, rather than only when releasing a key that's part of the configured keybind combination.
Possible fix
Adding a check to verify the released key is part of the keybind before evaluating the toggle condition might resolve this. Maybe something like:
On initial testing this seems to have fixed it for me, but of course I may have overlooked something important, so don't take it too seriously.