fix(input): keys and mouse buttons stay held after alt-tab or a release outside the container

Đang mở Phù hợp với người mới
#481 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
84/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
frontend, testing

Hướng nghiên cứu

Đọc modules/input/src/keyboard-mouse/input-handler.ts quanh dòng 47–54 và bài kiểm thử hồi quy trong modules/input/test/keyboard-mouse/input.library.spec.ts quanh dòng 171–181. Kiểm tra cách các handler được đăng ký và gỡ bỏ trong destroy, sau đó chạy bài kiểm thử thư viện input. Công việc hoàn tất khi các mock riêng biệt cho container và window xác minh rằng trạng thái bàn phím và chuột được đặt lại khi mất tiêu điểm, khi trạng thái hiển thị thay đổi và khi nhả chuột bên ngoài container.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug modules:input tests
Which package is this bug report for?

input

Issue description

visibilitychange only fires on document, and blur does not bubble to a non-focusable div, so the reset handlers registered on the container never run. Holding W and alt-tabbing leaves KeyW true. A mouseup outside the container leaves the drag and the button state set. The unit test passes only because its mock container is the window mock (input.library.spec.ts:49-52).

Where:

Evidence:

container.addEventListener("mouseup", this.onMouseUp);
container.addEventListener("blur", this.onBlur);
container.addEventListener("visibilitychange", this.onVisibilityChange);

Suggested fix: Listen for blur and mouseup on window and for visibilitychange on container.ownerDocument, and remove them in destroy. Give the test a container mock that is not the window.

Found during a code audit of main at be72076.

Code sample

No response

Versions
  • Engine main at be72076
  • pnpm 12.0.0, Node.js 26, Bun 1.3.14
Issue priority

High (immediate attention needed)

I have tested this issue on a development release

be72076

Ngôn ngữ chính
TypeScript
Star
7
Fork
2
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
17

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NanoForge-dev/Engine

Tất cả issue của NanoForge-dev/Engine

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.