Repository navigation
Conversation
…e row after a block drag The toolbar's drag-end handler set an inline display of 'block', which overrode the stylesheet's flex layout and stacked the buttons in one column. Clear the inline display instead. A drag also ends without the mouseup that turns the toolbar's pointer events back on, so turn them on there too; otherwise the first click on a button fell through to the editor and dropped the selection. Fixes meta#9964
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Hi @burrows99! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Thanks for the clear write-up and the before/after recording. This looks good to me.
The drag-end handler in packages/lexical-playground/src/plugins/FloatingTextFormatToolbarPlugin/index.tsx (lines 455-465) now clears the inline display, so the stylesheet's display: flex applies again. It also sets pointer-events: auto to undo what the mousemove listener writes when the drag starts. I reproduced both halves in Chromium on the playground's welcome content. On main the toolbar comes back as a single narrow column, and a click on Bold lands on the editor and clears the selection. With this change it comes back as one row and the same click bolds the selected word. The two new unit cases fail on main with expected 'block' to be '' and pass with the fix.
Optional, non-blocking suggestions:
- An E2E test for the real drag. The new cases in
__tests__/unit/FloatingTextFormatToolbar.test.tsxrun in jsdom, setpointer-events: noneby hand and check inline style strings, so they would not catch a regression in layout or in which element receives the click. AGENTS.md ("Testing Strategy") puts behaviour that depends on real layout and input in browser or E2E tests, and the E2E suite already has what this needs:dragDraggableMenuToinpackages/lexical-playground/__tests__/utils/index.mjs, used byDraggableBlock.spec.mjs. A spec that selects a word, drags a block by its handle, clicks Bold and asserts the word is bold would pin the behaviour users see. - Test plan output. AGENTS.md ("Commits and Pull Requests") asks the Test plan to paste the real failing output under Before as well as the passing output under After. The Before for the unit test is currently described rather than pasted.
No changeset is needed: the change is confined to the playground, which CONTRIBUTING.md and AGENTS.md exempt.
There was a problem hiding this comment.
Thanks for the fix, this looks good to me. Clearing the inline display lets the stylesheet's display: flex apply again. Resetting pointer-events in the same drag-end handler covers the mouseup that never arrives after an HTML5 drag. The new unit cases fail without the change and pass with it. The playground behaves as described: after a block is dropped, the toolbar is a row and Bold formats the selection, including when the drag ends with only dragend (released outside the editor).
Optional, non-blocking suggestions:
- An E2E for the drag-then-click path in
packages/lexical-playground/__tests__/e2e/DraggableBlock.spec.mjs. jsdom can't lay out flex or hit-test, so the unit cases check inline style values rather than what the user sees, and AGENTS.md (Testing Strategy) puts real layout and input behaviour in the browser and E2E tiers. One detail if you add one:dragDraggableMenuTo→dragMouse(__tests__/utils/index.mjs:1348-1354) moves from the handle to the target in one step. When I tried a direct move like that, the page saw no held-buttonmousemovebeforedragstart, and the toolbar stayed clickable even without the fix. Press the mouse and move a pixel or two before the long move to reproduce thepointer-eventshalf, then assert the popup's computeddisplayisflexand that clicking Bold makes the selected text bold. - Drive the real listener in the unit test (
FloatingTextFormatToolbar.test.tsx:120). Instead of settingpopup.style.pointerEvents = 'none'by hand, you could stubdocument.elementFromPoint(jsdom doesn't implement it) and dispatchnew MouseEvent('mousemove', {buttons: 1}). The test would then also break if the listener's condition changes. - Test plan output. AGENTS.md ("Commits and Pull Requests") asks the
### Beforesection to carry the pasted failing output of the command you ran. Theexpected 'block' to be ''failure from the vitest run would fit there.
No changeset is needed: AGENTS.md and CONTRIBUTING.md both exempt playground-only changes.
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
lexical
@lexical/a11y
@lexical/clipboard
@lexical/code
@lexical/code-core
@lexical/code-prism
@lexical/code-shiki
@lexical/compiler
@lexical/devtools-core
@lexical/dragon
@lexical/eslint-plugin
@lexical/extension
@lexical/fast-check
@lexical/file
@lexical/hashtag
@lexical/headless
@lexical/history
@lexical/html
@lexical/internal
@lexical/link
@lexical/list
@lexical/mark
@lexical/markdown
@lexical/mdast
@lexical/offset
@lexical/overflow
@lexical/plain-text
@lexical/react
@lexical/rich-text
@lexical/selection
@lexical/table
@lexical/tailwind
@lexical/text
@lexical/utils
@lexical/y
@lexical/yjs
commit: |
…floating toolbar drag test Stub document.elementFromPoint (jsdom has none) and dispatch a held-button mousemove instead of setting pointer-events by hand, so the case also breaks if the listener's condition changes.
There was a problem hiding this comment.
Thanks for the fix, this looks good. Clearing the inline display lets the stylesheet's display: flex apply again, and restoring pointer-events in the same drag-end handler covers an HTML5 drag ending without the mouseup that would normally turn them back on. The updated test now drives the real mousemove listener, so both the drop and dragend cases fail without the fix and pass with it.
Optional, non-blocking suggestions:
- An end-to-end case for the user-visible behaviour (
packages/lexical-playground/__tests__/e2e/DraggableBlock.spec.mjs). The unit cases assert inline style values, which is what jsdom can see; the stacked column and the click falling through to the editor only show up in a real browser, and AGENTS.md's testing strategy puts behaviour that depends on real layout in browser or E2E tests. A case that selects a word, drags a block withdragDraggableMenuTo, clicks the floating toolbar's Bold button and asserts the word is bold would keep both halves of this fix from regressing. - Test plan output (nit). AGENTS.md (Commits and Pull Requests) asks
### Beforeand### Afterto carry the command you ran with its real failing and passing output. Pasting the fullvitestfailure frommainunder### Beforeand the passing run under### Afterwould match that; the description of the playground behaviour can stay beside it.
No changeset is needed: CONTRIBUTING.md and AGENTS.md exempt playground-only changes, and a maintainer can add the skip-changeset label if CI asks for one.
Description
After a block is dragged by its handle and dropped while text is selected, the playground's floating format toolbar comes back squeezed into one narrow column, and its buttons do not respond to the first click.
Two things in
FloatingTextFormatToolbarPlugincause it:display: noneondragstart. Ondrop/dragendit was set back todisplay: block, which overrides the stylesheet'sdisplay: flex, so the buttons wrap into a single column. It now clears the inline value ('') so the stylesheet applies again.mousemovelistener setspointer-events: none, and only amouseupturns it back on. An HTML5 drag ends withdrop/dragendand nomouseup, so the toolbar stayed click-through: clicking Bold after a drop hit the editor underneath and cleared the selection. The same drag-end handler now setspointer-events: auto.flowchart TD A[Select text then drag a block by its handle] --> B{Drop the block} B -->|Before| C[Toolbar is one narrow column and Bold clicks fall through] B -->|After| D[Toolbar is one row and Bold formats the selection]Closes #9964
Changeset
None: the change is in the playground only (no published package changes).
Test plan
Narrated recording, before then after (sound on):
evidence.mp4
The recording drives the playground dev server (
?emptyEditor=falsefor the welcome content) in headless Chrome: select text, drag the "Lastly..." paragraph by its handle, drop it, then click Bold.Before
The toolbar comes back as a single column of buttons (inline style
display: block; pointer-events: none); clicking Bold clears the selection and nothing is formatted.After
The toolbar comes back as one row (inline
displaycleared,pointer-events: auto); clicking Bold formats the selected text.Edge cases and unchanged behaviour checked
In the running playground (shown in the third part of the video):
dropstill fires); the toolbar is one row and Strikethrough works.By unit test only: the
dragendpath (a drag that ends without a drop on the page).Automated
Added two cases to
packages/lexical-playground/__tests__/unit/FloatingTextFormatToolbar.test.tsx(one per drag-end event:dropanddragend). They fail onmain(expected 'block' to be '') and pass with the fix.prettier --checkandeslintpass on both changed files. I did not run the fullci-check(tsc / flow) or the e2e suites.AI assistance (Claude Code) was used to investigate, write and record this change.
🤖 Generated with Claude Code