Skip to content

Commit 601edb5

Browse files
Merge pull request #2363 from zetkin/release-241120
241120 Release
2 parents c97b40a + 2355973 commit 601edb5

File tree

3 files changed

+14
-38
lines changed

3 files changed

+14
-38
lines changed

src/features/emails/components/EmailEditor/EmailEditorFrontend.tsx

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -118,25 +118,6 @@ const EmailEditorFrontend: FC<EmailEditorFrontendProps> = ({
118118
},
119119
};
120120

121-
// What this event handler does is prevent the editor.js-window from
122-
// hijacking the focus when typing a '/' anywhere else outside of the editor
123-
// Unfortunately, this is not an ideal fix, as it prevents any other event
124-
// handlers from firing, not just the ones inside the editor.js, unless they
125-
// were added before this one.
126-
// This seems to be the only viable fix, since there is no way to disable
127-
// the event listeners in editor.js, except by making the editor readonly,
128-
// which we obviously don't want to do.
129-
// This is where the event handlers are attached: https://github.com/codex-team/editor.js/blob/58a7a9eeeadbfaef3c256576c8f37d64cb5d0edf/src/components/modules/ui.ts#L393-L395
130-
const keyDownHandler = (e: KeyboardEvent) => {
131-
const inside = !!(e.target as HTMLElement).closest?.(
132-
'#ClientOnlyEditor-container'
133-
);
134-
if (!inside) {
135-
e.stopImmediatePropagation();
136-
}
137-
};
138-
document.addEventListener('keydown', keyDownHandler, true);
139-
140121
// Create the EditorJS instance
141122
editorInstance.current = new EditorJS(editorConfig);
142123

@@ -148,7 +129,6 @@ const EmailEditorFrontend: FC<EmailEditorFrontendProps> = ({
148129
setEditorJSApiRef();
149130

150131
return () => {
151-
document.removeEventListener('keydown', keyDownHandler, true);
152132
// Cleanup when the component is unmounted
153133
if (editorInstance.current) {
154134
try {

src/features/search/components/SearchDialog/index.tsx

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,21 @@ const SearchDialog: React.FunctionComponent<{
3535
setOpen(false);
3636
};
3737

38-
// We want this `keydown` event handler to run in the capturing-phase, and
39-
// that it is only attached on mount. This is to make sure that this handler
40-
// runs before the `keydown` event handler in `EmailEditorFrontend`, which
41-
// stops propagation in order to prevent editor.js from hijacking focus.
42-
useEffect(() => {
43-
const handleKeydown = (e: KeyboardEvent) => {
44-
if (!isUserTyping(e)) {
45-
if (e.key === '/') {
46-
e.preventDefault();
47-
setOpen(true);
48-
}
38+
const handleKeydown = (e: KeyboardEvent) => {
39+
if (!isUserTyping(e)) {
40+
if (e.key === '/') {
41+
e.preventDefault();
42+
setOpen(true);
4943
}
50-
};
44+
}
45+
};
5146

52-
document.addEventListener('keydown', handleKeydown, true);
47+
useEffect(() => {
48+
document.addEventListener('keydown', handleKeydown);
5349
return () => {
54-
document.removeEventListener('keydown', handleKeydown, true);
50+
document.removeEventListener('keydown', handleKeydown);
5551
};
56-
}, []);
52+
});
5753

5854
useEffect(() => {
5955
router.events.on('routeChangeStart', handleRouteChange);

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,9 +1635,9 @@
16351635
integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==
16361636

16371637
"@editorjs/editorjs@^2.28.2":
1638-
version "2.30.6"
1639-
resolved "https://registry.yarnpkg.com/@editorjs/editorjs/-/editorjs-2.30.6.tgz#a77292da7433bc912e4beaf359b13812cab89c4d"
1640-
integrity sha512-6eQMc4Di3Hz9p4o+NGRgKaCeAF7eAk106m+bsDLc4eo94VGYO1M163OiGFdmanE+w503qTmXOzycWff5blEOAQ==
1638+
version "2.29.0"
1639+
resolved "https://registry.yarnpkg.com/@editorjs/editorjs/-/editorjs-2.29.0.tgz#1c9846af19b2afab62a6bb3a815641721c0587f1"
1640+
integrity sha512-w2BVboSHokMBd/cAOZn0UU328o3gSZ8XUvFPA2e9+ciIGKILiRSPB70kkNdmhHkuNS3q2px+vdaIFaywBl7wGA==
16411641

16421642
"@editorjs/header@^2.8.1":
16431643
version "2.8.1"

0 commit comments

Comments
 (0)