Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/core/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,8 @@ export class CliRenderer extends EventEmitter implements RenderContext {
}

if (mouseEvent.type === "up" && this.currentSelection?.isDragging) {
this.updateSelection(maybeRenderable, mouseEvent.x, mouseEvent.y)

if (maybeRenderable) {
const event = new MouseEvent(maybeRenderable, { ...mouseEvent, isDragging: true })
maybeRenderable.processMouseEvent(event)
Expand Down
31 changes: 31 additions & 0 deletions packages/core/src/tests/renderer.mouse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,37 @@ describe("renderer handleMouseData", () => {
}
})

test("selection mouseUp without drag events updates focus to release coordinates", async () => {
try {
const target = new TestRenderable(renderer, {
id: "selectable-no-drag",
position: "absolute",
left: 2,
top: 2,
width: 20,
height: 6,
})
target.selectable = true
renderer.root.add(target)
await renderOnce()

const startX = target.x + 1
const startY = target.y + 1
const endX = target.x + 15
const endY = target.y + 1

await mockMouse.pressDown(startX, startY)
// No moveTo — simulates a terminal multiplexer that does not forward drag events
await mockMouse.release(endX, endY)

const selection = renderer.getSelection()
expect(selection).not.toBeNull()
expect(selection?.focus).toEqual({ x: endX, y: endY })
} finally {
renderer.destroy()
}
})

test("mouse out is not fired on a destroyed renderable before render", async () => {
try {
const target = new TestRenderable(renderer, {
Expand Down
Loading