From 69d1bc8600ffda64d48257cfb3e916a4e995a6bc Mon Sep 17 00:00:00 2001 From: Mateusz Debinski Date: Tue, 7 Jan 2020 14:58:19 +0100 Subject: [PATCH 1/6] EZP-31266: Changing items order in Relation List doesn't work on Firefox --- .../js/scripts/fieldType/ezobjectrelationlist.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js b/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js index 4d82223717..9702e5c4bb 100644 --- a/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js +++ b/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js @@ -215,7 +215,15 @@ return [...relationsContainer.querySelectorAll('[type="checkbox"]')]; }; const attachRowsEventHandlers = () => { - findOrderInputs().forEach((item) => item.addEventListener('blur', updateSelectedItemsOrder, false)); + findOrderInputs().forEach((item) => { + item.addEventListener('blur', updateSelectedItemsOrder, false); + item.addEventListener('change', focusOnElement, false); + }); + }; + const focusOnElement = (event) => { + if(doc.activeElement !== event.target) { + event.target.focus(); + } }; const emptyRelationsContainer = () => { while (relationsContainer.lastChild) { From 217b5ba5677f90faddbcc872a4304b98a76fc2c7 Mon Sep 17 00:00:00 2001 From: Mateusz Debinski Date: Tue, 7 Jan 2020 15:23:36 +0100 Subject: [PATCH 2/6] reformatting code with prettier --- .../public/js/scripts/fieldType/ezobjectrelationlist.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js b/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js index 9702e5c4bb..1d102dbfac 100644 --- a/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js +++ b/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js @@ -221,7 +221,7 @@ }); }; const focusOnElement = (event) => { - if(doc.activeElement !== event.target) { + if (doc.activeElement !== event.target) { event.target.focus(); } }; @@ -264,9 +264,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); From 5a2097a1cb40a780cde7d2713d4fd97729c41472 Mon Sep 17 00:00:00 2001 From: Mateusz Debinski Date: Tue, 7 Jan 2020 15:40:00 +0100 Subject: [PATCH 3/6] Attach only for FF --- package.json | 1 + .../public/js/scripts/fieldType/ezobjectrelationlist.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f6a981c998..0dddd9d91e 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "clean-webpack-plugin": "^0.1.16", "css-loader": "^0.28.5", "eslint-plugin-react": "^7.3.0", + "prettier": "^1.19.1", "prop-types": "^15.5.10", "style-loader": "^0.18.2", "uglifyjs-webpack-plugin": "^0.4.6", diff --git a/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js b/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js index 1d102dbfac..3f277bc89f 100644 --- a/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js +++ b/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js @@ -215,9 +215,12 @@ return [...relationsContainer.querySelectorAll('[type="checkbox"]')]; }; const attachRowsEventHandlers = () => { + const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; findOrderInputs().forEach((item) => { item.addEventListener('blur', updateSelectedItemsOrder, false); - item.addEventListener('change', focusOnElement, false); + if (isFirefox) { + item.addEventListener('change', focusOnElement, false); + } }); }; const focusOnElement = (event) => { From aa131f662129857127ca47a7d5b413043905731d Mon Sep 17 00:00:00 2001 From: mateuszdebinski <58430570+mateuszdebinski@users.noreply.github.com> Date: Tue, 7 Jan 2020 15:42:23 +0100 Subject: [PATCH 4/6] Update src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js Co-Authored-By: Dariusz Szut --- .../public/js/scripts/fieldType/ezobjectrelationlist.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js b/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js index 3f277bc89f..4e2852febb 100644 --- a/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js +++ b/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js @@ -216,6 +216,7 @@ }; const attachRowsEventHandlers = () => { const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; + findOrderInputs().forEach((item) => { item.addEventListener('blur', updateSelectedItemsOrder, false); if (isFirefox) { From 140f2dd4dcbe3fd1c5fa24f21ab4209b98b50302 Mon Sep 17 00:00:00 2001 From: mateuszdebinski <58430570+mateuszdebinski@users.noreply.github.com> Date: Tue, 7 Jan 2020 15:42:29 +0100 Subject: [PATCH 5/6] Update src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js Co-Authored-By: Dariusz Szut --- .../public/js/scripts/fieldType/ezobjectrelationlist.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js b/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js index 4e2852febb..68983d4856 100644 --- a/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js +++ b/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js @@ -219,6 +219,7 @@ findOrderInputs().forEach((item) => { item.addEventListener('blur', updateSelectedItemsOrder, false); + if (isFirefox) { item.addEventListener('change', focusOnElement, false); } From 87106c58879c291e5c5c1b4b8c9969b7b1b6c5ac Mon Sep 17 00:00:00 2001 From: Mateusz Debinski Date: Tue, 7 Jan 2020 15:48:55 +0100 Subject: [PATCH 6/6] remove prettier --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 0dddd9d91e..f6a981c998 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "clean-webpack-plugin": "^0.1.16", "css-loader": "^0.28.5", "eslint-plugin-react": "^7.3.0", - "prettier": "^1.19.1", "prop-types": "^15.5.10", "style-loader": "^0.18.2", "uglifyjs-webpack-plugin": "^0.4.6",