Skip to content

Commit f2b54b5

Browse files
authored
fix(richtext-lexical, ui): opening relationship field with appearance: "drawer" inside rich text inline block (#12529)
To reproduce this bug, insert the following feature into the richtext editor: ```ts BlocksFeature({ inlineBlocks: [ { slug: 'inline-media', fields: [ { name: 'media', type: 'relationship', relationTo: ['media'], admin: { appearance: 'drawer', }, }, ], }, ], }), ``` Then try opening the relationship field drawer. The inline block drawer will close. Note: Interestingly, at least in Chrome, this only happens with DevTools closed. It worked fine with DevTools open. It probably has to do with capturing events like focus. The current solution is a 50ms delay. I couldn't test it with CPU throttle because it disappears when I close the devtools. If you encounter this bug, please open an issue so we can increase the delay or, better yet, find a more elegant solution.
1 parent 4a41369 commit f2b54b5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/ui/src/fields/Relationship/Input.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,11 @@ export const RelationshipInput: React.FC<RelationshipInputProps> = (props) => {
768768
}}
769769
onMenuOpen={() => {
770770
if (appearance === 'drawer') {
771-
openListDrawer()
771+
// TODO: This timeout is only necessary for inline blocks in the lexical editor
772+
// and when the devtools are closed. Temporary solution, we can probably do better.
773+
setTimeout(() => {
774+
openListDrawer()
775+
}, 50)
772776
} else if (appearance === 'select') {
773777
setMenuIsOpen(true)
774778
if (!hasLoadedFirstPageRef.current) {

0 commit comments

Comments
 (0)