mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-24 20:45:56 +03:00
[PR #480] [MERGED] fix(hitgrid): stale hit grid after scroll/translate #567
Labels
No labels
bug
core
documentation
feature
good first issue
help wanted
pull-request
question
react
solid
tmux
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/opentui#567
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/anomalyco/opentui/pull/480
Author: @simonklee
Created: 1/6/2026
Status: ✅ Merged
Merged: 1/8/2026
Merged by: @kommander
Base:
main← Head:ctrl-p-mouse📝 Commits (10+)
6f11e5dfix(hitgrid): stale hit grid after scroll/translate44f0af2rebase main and use ArrayListUnmanaged48c5069fix formatter error2a795cfcore: guard render loop after destroye352507fix(renderer): defer native teardown until frame completes1328f06format6e5b5e2perf(hitgrid): skip Yoga sync during hit grid rebuildd66ee28remove unused methodse36f8bcsimplify2b34ce6pure command📊 Changes
10 files changed (+1123 additions, -76 deletions)
View changed files
📝
packages/core/src/Renderable.ts(+9 -2)➕
packages/core/src/examples/scrollbox-mouse-test.ts(+112 -0)➕
packages/core/src/examples/scrollbox-overlay-hit-test.ts(+206 -0)📝
packages/core/src/renderer.ts(+120 -70)📝
packages/core/src/tests/renderer.destroy-during-render.test.ts(+46 -0)➕
packages/core/src/tests/scrollbox-hitgrid.test.ts(+393 -0)📝
packages/core/src/types.ts(+3 -0)📝
packages/core/src/zig.ts(+59 -0)📝
packages/core/src/zig/lib.zig(+20 -0)📝
packages/core/src/zig/renderer.zig(+155 -4)📄 Description
Add immediate hit grid sync for scroll and translate changes
Before this change, when a scrollbox scrolled, the hit grid stayed stale until the next render completed. Hover states wouldn't update even though elements visually moved. Users would hover over items that had already scrolled away.
The fix adds on-demand hit grid sync. When translateX/Y changes, the renderer
marks the grid dirty and rechecks hover state. The renderer now:
The hit grid rebuild mirrors the render traversal but uses screen coordinates for scissor rects. Buffered renderables need this because they render at (0,0) in their local buffer, but hit testing happens in screen space.
Captured renderable (during drag) is excluded from the hit grid so drop targets receive events correctly.
I added the demo from #467 as an example as well as another debug example i used when implementing it. Both should probably be deleted before merging. You can copy these examples to 'main' to see the difference between how things react in main vs the branch.
The PR is a slightly different approach than what you discussed in https://github.com/anomalyco/opentui/pull/470#issuecomment-3711893881 comment, and I don't mind if you prefer your approach, but maybe you'll find some ideas here.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.