浮动 Git tab 的右下角 20×20 手柄([data-dockkit-float-resize])是浮窗的 最后一个子节点,但宿主给它 z-index: auto;Git footer 的 sticky + z-index:1 正好盖在角上,手柄既看不见也点不到,整个浮窗无法用指针缩放。实测文件 tab 的浮窗正常(底部没有 stacking 栏),只有带底栏的 tab 中招。 - 把宿主手柄抬到 z-index:2:覆盖第三方 tab 内容,不依赖插件自己的底栏; - 收掉 .gitFooter 的 z-index:sticky + 定位已足够压在滚动行之上,这一层 在没有该宿主属性的版本上也成立; - tests/float-resize-grip.spec.ts 钉住两条(含 z-index 必须 > 1)。
47 lines
2.3 KiB
TypeScript
47 lines
2.3 KiB
TypeScript
/**
|
||
* A floating tab must be resizable by pointer.
|
||
*
|
||
* The host renders the float's 20×20 resize grip (`data-dockkit-float-resize`)
|
||
* as its LAST child but at `z-index: auto`. Tab content that stacks above it
|
||
* takes the bottom-right corner away from the grip: on the real app a
|
||
* floating Git tab could not be resized at all (its footer is
|
||
* `position: sticky; z-index: 1`), while a floating file tab — whose bottom
|
||
* edge carries no stacking bar — resized normally. The failure is silent:
|
||
* the corner glyph never appears and the cursor never becomes `nwse-resize`.
|
||
*
|
||
* Two guards: the host hook is raised above that class of content (also
|
||
* covering third-party tab bodies we do not own), and the Git footer no
|
||
* longer stacks on its own, so the grip wins even on a host build without the
|
||
* attribute hook.
|
||
*/
|
||
import { readFileSync } from 'node:fs'
|
||
import { describe, expect, it } from 'vitest'
|
||
|
||
/** Strip block comments so prose mentions are not read as declarations. */
|
||
const stripComments = (text: string): string => text.replace(/\/\*[\s\S]*?\*\//g, '')
|
||
|
||
const shellCss = stripComments(readFileSync('src/client/sidebar.module.css', 'utf8'))
|
||
const changesCss = stripComments(readFileSync('src/client/changes/changes.module.css', 'utf8'))
|
||
|
||
describe('floating tab resize grip', () => {
|
||
it('raises the host grip above content that stacks at z-index 1', () => {
|
||
const rule = shellCss.match(/:global\(\[data-dockkit-float-resize\]\)\s*\{([^}]*)\}/)?.[1]
|
||
expect(rule, 'the [data-dockkit-float-resize] global rule must exist').toBeDefined()
|
||
const zIndex = Number(rule!.match(/z-index:\s*(\d+)/)?.[1])
|
||
// The Git footer used to stack at 1; anything <= 1 leaves it covering the
|
||
// grip again. Pin "above 1" rather than the exact literal so a future
|
||
// host/content z-index bump can move the value without re-breaking this.
|
||
expect(Number.isFinite(zIndex)).toBe(true)
|
||
expect(zIndex).toBeGreaterThan(1)
|
||
})
|
||
|
||
it('keeps the Git footer from stacking over the grip', () => {
|
||
const footer = changesCss.match(/\.gitFooter\s*\{([^}]*)\}/)?.[1]
|
||
expect(footer, 'the .gitFooter rule must exist').toBeDefined()
|
||
// Sticky stays: the footer must survive the host tab body scrolling.
|
||
expect(footer).toMatch(/position:\s*sticky/)
|
||
expect(footer).toMatch(/bottom:\s*0/)
|
||
expect(footer).not.toMatch(/(?:^|[;\s])z-index\s*:/)
|
||
})
|
||
})
|