mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
839d18425c
no refs The dropdown button component was missing `type="button"` when used as a button, which caused it to act like a `submit` button when used as part of a form, like in Member details page. This change adds type attribute to the button to fix the issue.
30 lines
800 B
JavaScript
30 lines
800 B
JavaScript
import Component from '@ember/component';
|
|
import DropdownMixin from 'ghost-admin/mixins/dropdown-mixin';
|
|
import {computed} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default Component.extend(DropdownMixin, {
|
|
dropdown: service(),
|
|
|
|
tagName: 'button',
|
|
attributeBindings: ['href', 'role', 'type'],
|
|
role: 'button',
|
|
|
|
// matches with the dropdown this button toggles
|
|
dropdownName: null,
|
|
|
|
type: computed(function () {
|
|
return this.tagName === 'button' ? 'button' : null;
|
|
}),
|
|
|
|
// Notify dropdown service this dropdown should be toggled
|
|
click(event) {
|
|
this._super(event);
|
|
this.dropdown.toggleDropdown(this.dropdownName, this);
|
|
|
|
if (this.tagName === 'a') {
|
|
return false;
|
|
}
|
|
}
|
|
});
|