fix(webui): fix arrow key frame rounding and duplicate event bubbling

- Use Math.round instead of Math.floor for keyboard arrow frame navigation in ModelViewer
- Add e.stopPropagation() to RulerSlider keyboard events to prevent duplicate bubbling to window listener
This commit is contained in:
yiling
2026-10-09 12:25:05 +08:00
parent 7c264ee447
commit 8446eaba94
3 changed files with 14 additions and 2 deletions
@@ -104,6 +104,14 @@ describe('ModelViewer', () => {
fireEvent.keyDown(window, { key: 'ArrowRight' })
expect(onTimeUpdate).toHaveBeenCalledWith(expect.closeTo(1 / 6, 2))
// Press ArrowRight second time -> advance to frame 2 (30 deg = 2/6 sec)
fireEvent.keyDown(window, { key: 'ArrowRight' })
expect(onTimeUpdate).toHaveBeenCalledWith(expect.closeTo(2 / 6, 2))
// Press ArrowLeft -> back 1 frame (frame 1 = 1/6 sec)
fireEvent.keyDown(window, { key: 'ArrowLeft' })
expect(onTimeUpdate).toHaveBeenCalledWith(expect.closeTo(1 / 6, 2))
// Press ArrowLeft -> back 1 frame (frame 0 = 0 sec)
fireEvent.keyDown(window, { key: 'ArrowLeft' })
expect(onTimeUpdate).toHaveBeenCalledWith(0)