Skip to content

Commit b7c315f

Browse files
committedOct 2, 2023
Fix suggestions does not close after selection
1 parent 70cadcf commit b7c315f

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed
 

‎packages/ra-input-rich-text/src/RichTextInput.stories.tsx

+8-9
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ const suggestions = tags => {
375375
},
376376

377377
onKeyDown(props) {
378-
if (props.event.key === 'Escape') {
378+
if (popup && popup[0] && props.event.key === 'Escape') {
379379
popup[0].hide();
380380

381381
return true;
@@ -396,15 +396,14 @@ const suggestions = tags => {
396396
if (component) {
397397
component.destroy();
398398
}
399+
// Remove references to the old popup and component upon destruction/exit.
400+
// (This should prevent redundant calls to `popup.destroy()`, which Tippy
401+
// warns in the console is a sign of a memory leak, as the `suggestion`
402+
// plugin seems to call `onExit` both when a suggestion menu is closed after
403+
// a user chooses an option, *and* when the editor itself is destroyed.)
404+
popup = undefined;
405+
component = undefined;
399406
});
400-
401-
// Remove references to the old popup and component upon destruction/exit.
402-
// (This should prevent redundant calls to `popup.destroy()`, which Tippy
403-
// warns in the console is a sign of a memory leak, as the `suggestion`
404-
// plugin seems to call `onExit` both when a suggestion menu is closed after
405-
// a user chooses an option, *and* when the editor itself is destroyed.)
406-
popup = undefined;
407-
component = undefined;
408407
},
409408
};
410409
},

0 commit comments

Comments
 (0)
Please sign in to comment.