Skip to content

Commit

Permalink
IBX-9137: Fixed disabled state on translate button when no languages … (
Browse files Browse the repository at this point in the history
  • Loading branch information
dew326 authored Oct 24, 2024
1 parent 2867274 commit 881be3b
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
(function (global, doc) {
const SELECTOR_MODAL = '.ibexa-modal';
const toggleBtnDisabledState = (select) => {
const modal = select.closest(SELECTOR_MODAL);
const buttonCreate = modal.querySelector('.ibexa-btn--create-translation');

buttonCreate.toggleAttribute('disabled', !select.value);
};

doc.querySelectorAll('.ibexa-translation__language-wrapper--language').forEach((select) => {
select.addEventListener(
'change',
(event) => {
const modal = event.target.closest(SELECTOR_MODAL);
const buttonCreate = modal.querySelector('.ibexa-btn--create-translation');
const method = event.target.value ? 'removeAttribute' : 'setAttribute';
toggleBtnDisabledState(select);

buttonCreate[method]('disabled', true);
},
false,
);
select.addEventListener('change', toggleBtnDisabledState, false);
});
})(window, window.document);

0 comments on commit 881be3b

Please sign in to comment.