Repository navigation
Port lf-board and lf-card to Effect UI, with the drag held in the Model - #7573
Conversation
There was a problem hiding this comment.
test_a_detached_board_lets_go_of_a_held_card_and_drags_again_once_back fails in CI's test job, and every time I run it locally on an idle 4-core runner, alone or with others: wait_for_selector("#col-done #card-heater") times out. The board's behaviour is correct. The test has a race. The keyboard grab leaves #card-heater in #col-done when the board is removed. When the board comes back, a fresh root draws the state and arrange glides the card home over 150 ms. The test reads the grip's bounding_box() while the card is still at its painted mid-glide position, so mouse.down lands where the grip no longer stands, and the press never reaches it. In a probe, getAnimations().length on the card was 1 right after the append. The drag passes every time once the test waits for the glide to end, as test_cancelling_a_pointer_drag_restores_the_card_without_a_move already does before its next press. The suggestion adds that wait.
The same job also fails tests/model/test_theme_tokens.py::test_a_bundled_package_names_only_the_names_of_leaf_s_its_references_declare on packages/default/styles/board.css: --lf-z-page-paint. The new z-index: var(--lf-z-page-paint) on lf-board .lf-motion-preview reads a token that browser/styles/tokens.css defines for Leaf's own chrome (chrome.css is its only other reader), and no package reference declares it. Another author's package can't rely on that name, so a bundled one shouldn't either (root AGENTS.md, "Keep the package interface small"). The cheaper fix is a value the package owns, since the label only has to paint above the page's own content. Declaring the token in package-themes.md would add a name to the package interface, and that is the maintainer's call.
…ched-board test presses the grip once it rests
leaf-agent
left a comment
There was a problem hiding this comment.
pnpm run check fails on this head merged with main, so the test job stops before pytest runs: lf-board.ts, at the defineWidget("lf-board", Board, …) call, gives TS2379 … Type 'Covariant<unknown>' is not assignable to type 'Covariant<Provided>'. #7575 typed defineWidget over its component, so a component whose requirements widen to unknown no longer type-checks. Here the any comes from Step: evolve: (fields: Partial<Model>) => any makes send and drop return any, and that erases the update's requirements. When I set that return type to never as a probe, the error at the defineWidget call went away and only the expected .run-on-never errors were left. So typing Step as the update's own $ should fix it, the same way #7575 removed the view anys in lf-toc and lf-draft.
The new shadow root puts the grip before the card's words, so a screen reader hears "Move: Heated perch — Todo" before the title, and Tab reaches the grip before any link the card's words hold. board.css gives the opposite as the reason for the grip's layout: "The float is generated rather than the grip itself floated, which would have to come first in the card and so be read before its title." The grip is position: absolute against the card (card-shadow.css), so its place in the root doesn't change where it paints. Drawing it after h.slot.key("words") keeps the order the card had before main put the light box first. The rewritten aria snapshots in test_a_board_says_which_column_each_card_is_in then go back to title-first, and the header comment "the grip before them, as it stands in the card's top corner" needs the same correction.
Locally, the board tests for reading order, the phone's Move to buttons, the grip and the detached board all pass on this head.
…s view Main now draws a light widget's box before its authored children (#7572), which put a card's phone buttons above its title and pushed every title below the grip's room. The card draws on both sides of its words, so it takes a shadow root, as the Renderers rule says: the grip before the slot, where it stands in the card's top corner, and the Move to buttons after it. Its rules move to styles/card-shadow.css under `:host(lf-card)`. A screen reader now reads the grip before the card's title; stills of the board at rest, grabbed, moved and moved on a phone show 0 px against main. Margin layout read a shadow host whole as cover even where the host was the pin's own target, so a comment pin by a card stood above it, over its column's count. The walk now crosses the target's own shadow tree, as it crosses those of the hosts holding it; the board case of the pin catalogue caught it. The grip draws its symbol face with `actionPress` and states the board's rows with `Keys`. The rows stay functions the board makes, since a row's `message` reaches the component that drew it. module-widgets.md says how Mount args compare on each draw and that two Mounts' messages reach `update` in no fixed order. The page-CSS tests read a draft's controls, since a page's rules don't reach the cards' shadow trees, and the module test serves a page with no shadow widget for the case that never asks for shadow.css.
…a part `defineWidget` now types its component (#7575), and the board's own `Step` type, whose `evolve` returned `any`, left the component requiring `unknown`; it is the component's `Component.Update` now. The grip stands in the card's shadow root, so the site's recipe for styling a control a widget builds, `lf-board .lf-grip`, reached nothing. The grip is the card's `grip` part, the recipe says `lf-card::part(grip)`, and the theme-package test checks it. Margin layout reads the target's own shadow tree for what a pin covers, so it now hears changes there too, as it hears those in the trees holding the target: a control revealed under a pin in a widget whose size stays put moves the pin. `cardHolding` finds the card through `shadowHost`, and module-widgets.md says when a Mount compares its args: on a draw that gives it new ones.
Margin layout heard attribute changes in the target's own shadow tree but dropped a node added there, unless the node held a target: a widget that draws in a shadow root of its own could add a button under its pin without changing its size, and the pin kept its seat over the button. A change anywhere in such a tree now places the pins again, and a test adds a button under a card's pin and waits for the pin to move off it. module-widgets.md says a Mount's `changes` hear later args that differ from the last it heard, rather than claiming a comparison on every draw.
… each pass A tree stayed in the set after its last comment went, so every later change inside that widget placed every pin again. Each pass now states the set, as it states the boxes it watches. module-widgets.md says a Mount's changes compare a draw's args with the draw before's, and that Equal.equals can walk the values.
leaf-agent
left a comment
There was a problem hiding this comment.
The test check was still running on this head when I approved it.
…reads first The grip stands first in the card's shadow root and is read before the title, so the old reason, that a floated grip would be read first, no longer holds; the room stands before the card draws its grip.
Ports
lf-boardandlf-cardto Effect UI components (defineWidget) and removes SortableJS. It supersedes the draft #7470, which kept Sortable moving the cards.How a move works. The board's Model holds the card the user holds, where it was picked up and the placement drawn meanwhile, with the card where it would land; and, from a drop until Leaf's next reading, the placement the drop left. The view draws that placement, else Leaf's
state, and one Mount places the author'slf-cardnodes to match with Leaf'smove. A drop, a cancel, an undo, a refusal and a revision all place cards the same way, and nothing moves a node behind the renderer. A drop records the existingmoveverb withRecordAction, ranked among the neighbours the user saw.The drag uses Pointer Events through Leaf's
onPress, as Leaf's own drags do; the board finds the slot under the pointer and scrolls at an edge itself. SortableJS moves the card nodes; dnd-kit's feedback lifts the dragged node into the top layer beside a placeholder; Pragmatic drag and drop needs adraggablecard, in which Firefox lets nobody select words to comment on.The card draws on both sides of the author's words, its grip in the top corner and a phone's Move to buttons under the prose, so it draws in a shadow root (browser/AGENTS.md, "Renderers"), with its rules in
styles/card-shadow.css. Its grip draws its face withactionPressand states the board's key rows withKeys.What the port made easier. The gesture logic is one
updateunder Story tests (tests/runtime/lf-board-story.test.mjs); only browser tests covered it before.What a user sees differently. The label under the pointer is fully opaque, as
board.cssasks; Sortable's inlineopacity: 0.8overrode it. A screen reader reads a card's grip before its title.leaf-dev stillsshows no other difference.Also. Margin layout now crosses the shadow tree of a pin's own target instead of reading it whole as cover, which stood a card's comment pin above the card; and it no longer measures what a
display: noneelement holds inside a box-less wrapper.lf-suggestionkeeps its margin entries and emphasis when a move carries its card to another column (connectedMoveCallback,StaticRange); on main a moved suggestion lost its emphasis.Bench, ms of main-thread CPU at 256, before the card took its shadow root (
leaf-dev bench cards boards --input move --input key --input scroll --input revision --sizes 64,256 --rounds 3 --read cpu --base):The extra load is one Effect UI component per card and, on a page with no other Effect UI widget, the bundle's evaluation. A page whose only Effect UI widget is a board now loads Effect UI (192 KB gzipped) instead of Sortable (28 KB).