mirror of
https://github.com/stablyai/orca.git
synced 2026-10-24 08:03:58 +00:00
* Improve mobile session tab scrolling and editor keyboard layout - Auto-scroll the active session tab into view within the horizontal tab strip, using a new layout-aware utility with minimal scrolling. - Use visual viewport measurements in the editor WebView to accurately report keyboard insets and lift floating controls above the keyboard, as native events can under-report covered areas. * Fix active tab scrolling and normalize editor keyboard inset - Ensure the active session tab is scrolled into view immediately when its layout finishes to prevent it from remaining hidden off-screen. - Round, clamp, and validate WebView visualViewport bottom measurements to avoid rendering inconsistencies from fractional or invalid insets. - Trigger an immediate keyboard inset report on script initialization. * Update tabStripOffsetRef when scrolling mobile tab strip Ensure the cached offset is updated to match the next scroll position. Without this update, subsequent scroll calculations would use stale offset values.
67 lines
1.5 KiB
TypeScript
67 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { resolveTabStripScrollOffset } from './tab-strip-scroll'
|
|
|
|
describe('resolveTabStripScrollOffset', () => {
|
|
it('keeps the offset when the active tab is already fully visible', () => {
|
|
expect(
|
|
resolveTabStripScrollOffset({
|
|
tabX: 140,
|
|
tabWidth: 128,
|
|
viewportWidth: 360,
|
|
contentWidth: 800,
|
|
currentOffset: 100
|
|
})
|
|
).toBe(100)
|
|
})
|
|
|
|
it('scrolls left to reveal a tab off the left edge', () => {
|
|
expect(
|
|
resolveTabStripScrollOffset({
|
|
tabX: 50,
|
|
tabWidth: 128,
|
|
viewportWidth: 360,
|
|
contentWidth: 800,
|
|
currentOffset: 200,
|
|
margin: 12
|
|
})
|
|
).toBe(38)
|
|
})
|
|
|
|
it('scrolls right to reveal a tab off the right edge', () => {
|
|
expect(
|
|
resolveTabStripScrollOffset({
|
|
tabX: 640,
|
|
tabWidth: 128,
|
|
viewportWidth: 360,
|
|
contentWidth: 900,
|
|
currentOffset: 0,
|
|
margin: 12
|
|
})
|
|
).toBe(420)
|
|
})
|
|
|
|
it('clamps the offset to the content bounds', () => {
|
|
expect(
|
|
resolveTabStripScrollOffset({
|
|
tabX: 880,
|
|
tabWidth: 128,
|
|
viewportWidth: 360,
|
|
contentWidth: 900,
|
|
currentOffset: 0
|
|
})
|
|
).toBe(540)
|
|
})
|
|
|
|
it('returns the current offset when the viewport has not been measured', () => {
|
|
expect(
|
|
resolveTabStripScrollOffset({
|
|
tabX: 100,
|
|
tabWidth: 128,
|
|
viewportWidth: 0,
|
|
contentWidth: 0,
|
|
currentOffset: 0
|
|
})
|
|
).toBe(0)
|
|
})
|
|
})
|