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

EZP-31266: Changing items order in Relation List doesn't work on Firefox #1180

Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,20 @@
return [...relationsContainer.querySelectorAll('[type="checkbox"]')];
};
const attachRowsEventHandlers = () => {
findOrderInputs().forEach((item) => item.addEventListener('blur', updateSelectedItemsOrder, false));
const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
mateuszdebinski marked this conversation as resolved.
Show resolved Hide resolved

findOrderInputs().forEach((item) => {
item.addEventListener('blur', updateSelectedItemsOrder, false);

if (isFirefox) {
mateuszdebinski marked this conversation as resolved.
Show resolved Hide resolved
item.addEventListener('change', focusOnElement, false);
}
});
};
const focusOnElement = (event) => {
if (doc.activeElement !== event.target) {
event.target.focus();
}
};
const emptyRelationsContainer = () => {
while (relationsContainer.lastChild) {
Expand Down Expand Up @@ -256,9 +269,10 @@
updateAddBtnState();
attachRowsEventHandlers();

[...fieldContainer.querySelectorAll(SELECTOR_BTN_ADD), ...fieldContainer.querySelectorAll('.ez-relations__cta-btn')].forEach(
(btn) => btn.addEventListener('click', openUDW, false)
);
[
...fieldContainer.querySelectorAll(SELECTOR_BTN_ADD),
...fieldContainer.querySelectorAll('.ez-relations__cta-btn'),
].forEach((btn) => btn.addEventListener('click', openUDW, false));

trashBtn.addEventListener('click', removeItem, false);
relationsContainer.addEventListener('change', updateTrashBtnState, false);
Expand Down