Repository navigation
fix(extension): avoid overlapping page controls - #34
Merged
Merged
Conversation
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.
Intent
The developer wanted the Simple Words floating “sw” brand button to avoid visually and interactively overlapping with existing page controls near the active editor. They specifically required collision detection to focus on actual button-like clickable elements, not plain input or textarea fields, since the active drafting area should not block placement. They also pushed back on using broad [tabindex] avoidance because it would catch too many non-control containers and make positioning unstable. The intended change was to make placement collision-aware while excluding the active editor and avoiding only narrow selectors such as buttons, links, role-based buttons/menu items/options, submit/reset/button inputs, and summaries.
What Changed
Risk Assessment
✅ Low: The change is well-bounded to floating button placement, uses narrow clickable selectors with visibility filtering, and now short-circuits collision probing to limit refresh-path overhead.
Testing
npx vitest run test/uiPosition.test.ts test/content.test.ts -t "button|overlap|tabindex|position"npx playwright test e2e/button-overlap.spec.tsButton-like page control avoided
Broad tabindex container not avoided
Placement rectangle evidence
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
Round 1 - passed ✅
✅ **Rebase** - passed
Round 1 - passed ✅
🔧 **Review** - 1 issue found → auto-fixed (9)
Round 1 - found 1 warning
src/content.ts:580- Collision detection treats any matching element with a layout box as an obstacle, including controls hidden withvisibility: hidden; those invisible/non-interactive controls can push the Simple Words button away from otherwise valid placements. Filter out elements whose computed visibility is hidden/collapsed before adding their rects.Round 2 (auto-fix) - found 1 warning
src/content.ts:574- Button repositioning now scans every matching button/link-like element in the whole document and reads computed style plus layout for each one on every active-editor refresh, including scroll and resize paths. On pages with many links or controls this can introduce scroll/typing jank; constrain collision checks to candidate positions or otherwise avoid full-document layout reads for each refresh.Round 3 (auto-fix) - found 1 warning
src/content.ts:641- Collision discovery only samples the candidate button rect at its four corners and center, so a real page control that partially overlaps the future Simple Words button without covering one of those five points will not be included inavoidRectsand the button can still be placed on top of it. Sample enough of the candidate area or use a small bounding query/fallback for candidate regions rather than five points.Round 4 (auto-fix) - found 1 warning
src/content.ts:643- Overlap discovery now callselementsFromPointfor every pixel of each candidate button rectangle on every button reposition. With six candidates this is roughly 2,600-3,700 hit-tests per input, selectionchange, scroll, or resize while an editor is active, which can still cause page jank; replace the per-pixel grid with a bounded coarser sample plus targeted edge/center coverage, or debounce scroll-driven repositioning.Round 5 (auto-fix) - found 1 warning
src/content.ts:639- The bounded overlap scan samples each candidate at 8px intervals, so a small button-like control that overlaps the future Simple Words button between those sample rows/columns can still be missed and covered. Add deterministic coverage for small overlaps, such as sampling all candidate edges plus center bands at a tighter bound or falling back to measuring discovered nearby selector matches for the candidate region.Round 6 (auto-fix) - found 1 warning
src/content.ts:639- The collision pass now performs a dense 2px hit-test grid over all six candidate button rectangles, andpositionButtonruns from focus/input/selection plus scroll and resize refresh paths. That is about 1,000elementsFromPointcalls per refresh for a 24px button, which can still introduce typing or scroll jank on complex pages; keep deterministic overlap coverage without scanning every 2px cell, or debounce refreshes driven by scroll/resize.Round 7 (auto-fix) - found 1 warning
src/content.ts:643- The overlap discovery samples only the candidate rectangle perimeter plus one vertical center line, so a small clickable control fully inside the future Simple Words button area but away from those sampled lines is never added toavoidRectsand can still be covered. Add deterministic interior coverage, such as a bounded grid or a targeted fallback that checks nearby selector matches against each candidate rect.Round 8 (auto-fix) - found 1 warning
src/content.ts:644- Button positioning still performs 804elementsFromPointhit-tests per refresh for a 24px button because every candidate samples full top/bottom edges, three vertical lines, and an interior grid. SincepositionButtonis called from focus, input, selectionchange, scroll, and resize paths, this can cause typing or scroll jank on complex pages; keep bounded collision discovery but avoid probing every candidate so densely on every refresh, for example by throttling scroll/resize refreshes or only expanding sampling after a coarse collision hint.Round 9 (auto-fix) - found 1 warning
src/content.ts:598- Collision probing eagerly samples the entire candidate rectangle before knowing whether that candidate is blocked, so each blocked candidate still costs roughly 139elementsFromPointcalls and a worst-case refresh can probe all six candidates on scroll, resize, selection, or input. Short-circuit candidate probing as soon as a visible matching clickable element overlapping that candidate is found, or use a cheaper coarse pass before dense sampling.Round 10 (auto-fix) - passed ✅
Round 1 - found 1 info
e2e/button-overlap.spec.ts- new test file written by agent: e2e/button-overlap.spec.tsnpx vitest run test/uiPosition.test.ts test/content.test.ts -t "button|overlap|tabindex|position"npx playwright test e2e/button-overlap.spec.ts🔧 **Document** - 1 issue found → auto-fixed
Round 1 - found 1 warning
.agents/skills/simple-words-design/ui_kits/extension/README.md:9- The UI kit documentation still describes production placement as a compactswbutton near the lower-right edge of focused editable fields. The code now uses collision-aware placement: it starts from the lower-right candidate but can move to other candidate positions to avoid overlapping button-like page controls while excluding the active editor. Update this production-positioning note, and the duplicate statement on line 36, so design/prototype guidance does not preserve a stale lower-right-only behavior.Round 2 (auto-fix) - passed ✅
✅ **Lint** - passed
Round 1 - passed ✅
✅ **Push** - passed
Round 1 - passed ✅