Fixed dropdown elements staying open/fixed when moving settings panel

refs https://github.com/TryGhost/Team/issues/1219

- added `dropdown.closeDropdowns()` to the `{{movable}}` modifier when dragging starts
- updated ember-power-select derived inputs to close their dropdowns when the dropdown service triggers it's `'close'` event
This commit is contained in:
Kevin Ansfield 2021-11-12 15:26:57 +00:00
parent f112bd06c9
commit c128998d86
3 changed files with 36 additions and 0 deletions

View File

@ -2,10 +2,27 @@
import Component from '@glimmer/component';
import {action} from '@ember/object';
import {isBlank} from '@ember/utils';
import {inject as service} from '@ember/service';
export default class GhSearchInputTrigger extends Component {
@service dropdown;
inputElem = null;
constructor() {
super(...arguments);
this.dropdown.on('close', this, this.closeFromDropdown);
}
willDestroy() {
super.willDestroy(...arguments);
this.dropdown.off('close', this, this.closeFromDropdown);
}
closeFromDropdown() {
this.args.select.actions.close();
}
@action
registerInput(elem) {
this.inputElem = elem;

View File

@ -1,5 +1,20 @@
import PowerSelectTrigger from 'ember-power-select/components/power-select/trigger';
import {inject as service} from '@ember/service';
export default class Trigger extends PowerSelectTrigger {
@service dropdown;
constructor() {
super(...arguments);
this.dropdown.on('close', this, this.closeFromDropdown);
}
willDestroy() {
super.willDestroy(...arguments);
this.dropdown.off('close', this, this.closeFromDropdown);
}
closeFromDropdown() {
this.args.select.actions.close();
}
}

View File

@ -1,8 +1,11 @@
import Modifier from 'ember-modifier';
import {action} from '@ember/object';
import {guidFor} from '@ember/object/internals';
import {inject as service} from '@ember/service';
export default class MovableModifier extends Modifier {
@service dropdown;
moveThreshold = 3;
active = false;
@ -105,6 +108,7 @@ export default class MovableModifier extends Modifier {
Math.abs(Math.abs(this.initialX - eventX) - Math.abs(this.xOffset)) > this.moveThreshold ||
Math.abs(Math.abs(this.initialY - eventY) - Math.abs(this.yOffset)) > this.moveThreshold
) {
this.dropdown.closeDropdowns();
this.disableScroll();
this.disableSelection();
this.disablePointerEvents();