Ghost/ghost/admin/app/modifiers/select-on-click.js
Kevin Ansfield 524b23c182
Migrated staff user screen to Ember Octane patterns (#15532)
refs https://github.com/TryGhost/Ghost/issues/14101

- migrated staff user controller to native class syntax
- removed use of `{{action}}` helper
- moved from custom components to native `<input>` and `<textarea>` for form fields
  - added `{{select-on-click}}` modifier to cover the `<GhTextingInput @selectOnClick>` option behaviour for any input element
- added `submitForm()` test helper that finds closest `form` element and trigger's a `submit` event on it simulating <kbd>Enter</kbd> being pressed whilst a field has focus
2022-10-05 12:05:31 +01:00

18 lines
477 B
JavaScript

import Modifier from 'ember-modifier';
import {action} from '@ember/object';
import {registerDestructor} from '@ember/destroyable';
export default class SelectOnClickModifier extends Modifier {
modify(element) {
element.addEventListener('click', this.onClick);
registerDestructor(this, () => {
element.removeEventListener('click', this.onClick);
});
}
@action
onClick(event) {
event.currentTarget.select();
}
}