0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Fixed CMD+F and multiple post selection

fixes https://github.com/TryGhost/Team/issues/2939

When using CMD+F, the multiple selection list still thinks CMD is pressed because the keyup event is not fired. This is fixed by clearing the pressed keys when the window is blurred.
This commit is contained in:
Simon Backx 2023-04-11 15:35:27 +02:00
parent ee216038e9
commit 114a6eb953

View file

@ -27,6 +27,7 @@ export default class ListComponent extends Component {
window.removeEventListener('keydown', this.onKeyDow, {passive: true}); window.removeEventListener('keydown', this.onKeyDow, {passive: true});
window.removeEventListener('keyup', this.onKeyUp, {passive: true}); window.removeEventListener('keyup', this.onKeyUp, {passive: true});
window.removeEventListener('click', this.onWindowClicked, {passive: true}); window.removeEventListener('click', this.onWindowClicked, {passive: true});
window.removeEventListener('blur', this.onWindowBlur, {passive: true});
} }
@action @action
@ -34,6 +35,7 @@ export default class ListComponent extends Component {
window.addEventListener('keydown', this.onKeyDown, {passive: false}); window.addEventListener('keydown', this.onKeyDown, {passive: false});
window.addEventListener('keyup', this.onKeyUp, {passive: true}); window.addEventListener('keyup', this.onKeyUp, {passive: true});
window.addEventListener('click', this.onWindowClicked, {passive: true}); window.addEventListener('click', this.onWindowClicked, {passive: true});
window.addEventListener('blur', this.onWindowBlur, {passive: true});
} }
@action @action
@ -44,6 +46,14 @@ export default class ListComponent extends Component {
} }
} }
@action
onWindowBlur() {
// This is required because the keyup event won't be fired again
this.ctrlPressed = false;
this.metaPressed = false;
this.shiftPressed = false;
}
@action @action
onKeyDown(event) { onKeyDown(event) {
if (event.key === 'Control') { if (event.key === 'Control') {