Skip to content

Commit 5f90a29

Browse files
committed
Only focus wrapper when parent field editable
Fix #874
1 parent 20dd769 commit 5f90a29

2 files changed

Lines changed: 108 additions & 1 deletion

File tree

src/lib/services/contents/fields/rich-text/components/custom-node.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,12 @@ export const createCustomNodeClass = (componentDef) => {
225225
wrapper = /** @type {HTMLElement} */ (component.getElement());
226226

227227
window.requestAnimationFrame(() => {
228-
wrapper.focus();
228+
// Focus the wrapper if the parent field is editable. This is necessary because `i18n:
229+
// duplicate` field is rendered as a read-only textbox in non-default locales, which may
230+
// steal focus from the wrapper of the default locale
231+
if (wrapper.closest('[role="textbox"][aria-readonly="false"]')) {
232+
wrapper.focus();
233+
}
229234

230235
// Clean up when the parent field is unmounted (e.g. navigating away).
231236
wrapper.closest('.field')?.addEventListener('Unmount', cleanup, { once: true });

src/lib/services/contents/fields/rich-text/components/custom-node.test.js

Lines changed: 102 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)