Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-9137: Fixed disabled state on translate button when no languages … #1377

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Loading