Skip to content
18 changes: 8 additions & 10 deletions build/media_source/system/js/joomla-toolbar-button.w-c.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ window.customElements.define('joomla-toolbar-button', class extends HTMLElement
if (!Joomla) {
throw new Error('Joomla API is not properly initiated');
}

this.connectedCallback();
this.disabled = false;

// If list selection is required, set button to disabled by default
if (this.listSelection) {
this.setDisabled(true);
}


this.onChange = this.onChange.bind(this);

this.addEventListener('click', event => this.executeTask(event));
Expand All @@ -50,6 +42,12 @@ window.customElements.define('joomla-toolbar-button', class extends HTMLElement
const formSelector = this.form || 'adminForm';
this.formElement = document.getElementById(formSelector);

this.disabled = false;
// If list selection is required, set button to disabled by default
if (this.listSelection) {
this.setDisabled(true);
}

if (this.listSelection) {
if (!this.formElement) {
throw new Error(`The form "${formSelector}" is required to perform the task, but the form was not found on the page.`);
Expand Down Expand Up @@ -120,4 +118,4 @@ window.customElements.define('joomla-toolbar-button', class extends HTMLElement

return true;
}
});
});