fix: show session delete button after the list shifts under the cursor - #771
Open
killersteps wants to merge 1 commit into
Open
fix: show session delete button after the list shifts under the cursor#771killersteps wants to merge 1 commit into
killersteps wants to merge 1 commit into
Conversation
Deleting a session unmounts that row so the next row slides up into the same place. The pointer often has not moved, so mouseenter/:hover do not fire and the rename/delete buttons intermittently never appear. Track the pointer against row geometry, ignore synthetic pointerleave from the removed row, and treat the row under the cursor as hovered after the list reflows.
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.
Problem
Rename and delete on a session row only appear while that row is hovered. Hover is tracked with JS
mouseenter.After you delete a session, the row below it moves up into the same place. The pointer often has not moved. Browsers do not fire
mouseenter(and often do not update:hover) when layout moves an element under a stationary pointer, so the row now under the cursor hashovered === false.The delete button is then missing until the pointer leaves the row and comes back. This is intermittent: it happens when you delete one session and immediately hover the next one, or when the next row is already under the cursor.
Solution
Keep the existing per-row
mouseenter/mouseleavebehavior, and additionally:data-session-id) and treat the row under the cursor as hovered.pointerleave/mouseleavewhen the coordinates are still inside the list. Unmounting the deleted row synthesizes leave even though the cursor never left.Tests
components/SessionSidebar.test.mjsasserts the geometry probe, the synthetic-leave guard, andshowHover = hovered || pointerActive.node --experimental-strip-types --test components/SessionSidebar.test.mjspasses.问题
会话行的重命名 / 删除按钮只在悬停时出现,悬停状态靠 JS 的
mouseenter。删掉一条会话后,下面那一行会顶上来,占原来的位置。这时指针往往没动。元素是被布局挪到指针下面的,浏览器不会触发
mouseenter(:hover也经常不更新),于是现在指针底下的那一行hovered === false。删除按钮就不会出现,直到指针先离开再移回来。这是偶现的:删掉一个以后立刻悬停到下一条,或者下一条已经在指针下面时,就会踩中。
解决方案
保留原有的逐行
mouseenter/mouseleave,并额外:data-session-id)做命中检测,把指针下面的行当作已悬停。pointerleave/mouseleave。被删的那一行卸载时会合成 leave,但指针其实没离开列表。测试
components/SessionSidebar.test.mjs覆盖几何探测、合成 leave 防护,以及showHover = hovered || pointerActive。node --experimental-strip-types --test components/SessionSidebar.test.mjs通过。