Repository navigation
fix(toolbar): render lazy surfaces once their CSS applies in Safari - #78
Merged
Merged
Conversation
The phone status pill spans the docked bar's width 8px above it, in the band where the presence and Discord/GitHub/Privacy chips float, so a refused "/" pick, a removed format's Undo or an unavailable cell's reason covered them. Hide the chips while the bar holds a pill, as they already hide for the selection bar; they come back when it closes.
The colour hover preview drew one decoration over each selection range,
so Red text or Yellow highlight showed over inline code and code blocks
although applying never colours them: inlineCode excludes every mark
and a code block allows none.
setActionPreview now takes { attrs, mark } and decorates only the inline
nodes addMark would mark (the parent allows the mark and no mark on the
node excludes it), merging adjacent runs. A collaborator's redraw keeps
the same rule.
A highlight preview's run that starts after the selection nests the
blurred selection's span inside its mark, so the colour panel's
stylesheet keeps that tint off.
…loads A brush press before the lazy formatting engine landed went through runWithEngine, which runs a queued action only if the selection has not moved. For Paint format the next selection is the intended next step, so the press was dropped and the brush never showed pressed. The brushes now keep the press in paint-pending.ts: pressed at once, with the copy cursor and the pill, the pressed text kept as a session range that follows edits. Once the engine lands it arms on that range and paints a mouse selection made meanwhile (on touch, the second tap). Other queued actions keep the unmoved-selection rule.
A pointer-up that started in the text set the pending press's apply flag even for a plain click, and landing then painted whatever was selected, a keyboard selection too. Read the selection a frame after the pointer-up, as the armed listener does, keep it only when it is other text, and on landing paint only if it is still that selection; otherwise just arm. The touch second press keeps its selection the same way.
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md # tests/TESTING.md
# Conflicts: # CHANGELOG.md # tests/TESTING.md
A "/" typed while an earlier fetch of the menu chunk was still failing (the chunk runtime fetches a failed chunk once more, a moment later) joined that fetch. When it failed, nothing loaded the chunk again while the menu stayed open, so the menu never showed even once the chunk could load. A failed load is now fetched once more straight away.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
In Safari (WebKit), lazy surfaces could render unstyled for a moment while another lazy stylesheet was still loading. On a phone-width window, the docked bar showed Redo, the Insert label and cells narrower than 44px. At 1440px, the colour popover body showed as a column of bare icons. The WebKit pass in #67 found this.
The fix: the phone bar, every
lazySurface(colour popover, Insert steps, selection bubble, diagram templates, Your formats, the Continue chip) and the palette now first render only once the CSS loaded so far applies. The new helper islib/styles-applied.ts.Root cause
WebKit leaves a stylesheet that has loaded out of
document.styleSheets, and off the page, until every pending<link rel=stylesheet>has loaded or failed. Turbopack resolves a lazyimport()once the chunk's JS and CSS have loaded. In WebKit that sheet may still be inactive at that moment, because another preloaded CSS chunk (here the colour popover's or the table grid's) is still in flight. A per-frame sample during the hold showed this:min-width: autoand Redodisplay: flex, and some link with a non-null.sheetwas missing fromdocument.styleSheets.stylesApplied()checks that exact condition (every loaded link's sheet is indocument.styleSheets) once, then on each animation frame until it holds or 1.5 s pass.Why not the two approaches the task suggested:
loadevent cannot help. That event has already fired whenimport()resolves; the sheet is loaded but inactive.How verified
tests/e2e/mobile-bar-lazy-css.spec.ts. The test holds the colour popover CSS chunk while the window narrows to a phone width, then lets the held sheet load or fail (offline). It asserts that every animation frame in which the bar exists has 44px cells. A third case never releases the sheet and asserts the bar still shows (the 1.5 s cap).--repeat-each=5,--workers=2).next start, WebKit, the table grid CSS held):auto(unstyled);next dev.tests/unit/lib/styles-applied.test.ts:bun run check(warnings only, unchanged from main),bun run lint,bun run typecheckandbun run test(1238 pass) all pass.--project=webkit(--workers=2): 346 passed. The one failure is unrelated to this change:slash-menu"Home, End, Page Up and Page Down…" callsnewCDPSessionunguarded, so it can never pass on WebKit.selection-bubble"bubble-in-row matrix" failed once on a combined run ("some words" not found after an undo) and passed on four reruns. The phone-bar specs passed under--workers=2, so the "rerun with--workers=1" caveat intests/TESTING.mdis replaced by a description of the mechanism.auto, panelblock) by disabling the surface's own sheet for the shot.Bytes
Follow-ups
next/dynamicload (editor-app.tsx) is not waited for. Its CSS is part of the editor chunk group, and the app-shell skeleton covers that load.lazy-surfaces.spec.tsis not in the WebKit project'stestMatch.slash-menu.spec.tsneeds a CDP skip on WebKit (from main).lazySurfacewaits forstylesApplied, so removing the wait would be caught without WebKit.