Closed konstantinmuenster closed 1 year ago
Just had a look at it again. The menu actually sticks to the selection if the anchor element is correctly specified.
If, for example, your editor wrapper has a fixed height, you can use the element
property to set this scrollable element as the anchor.
<div id="editor-wrapper" style={{ maxHeight: '400px', overflowY: 'scroll' }}>
<LexicalComposer>
<RichTextPlugin
contentEditable={<ContentEditable spellCheck={false} />}
placeholder={<Placeholder />}
ErrorBoundary={LexicalErrorBoundary}
/>
<FloatingMenuPlugin
MenuComponent={YourFloatingMenuUI}
element={document.getElementById('editor-wrapper')}
/>
</LexicalComposer>
</div>
Then everything should work as expected 👍
if the editor content has a fixed height and
overflow:scroll
, the menu should stick at the selection positionhttps://github.com/konstantinmuenster/lexical-floating-menu/assets/46243719/d2e55c44-a198-462e-88f0-743dc6ae95e8