fix(ui): keep effort tag edge clicks out of the slider
This commit is contained in:
1 parent
d1cfada9eb
commit
53183d374c
3 files changed
+38
-16
No files matched your search
@@ -245,6 +245,25 @@ describe.skipIf(MODE === 'record').each([
|
||||
const defaultHeight = await menu.evaluate(element => element.getBoundingClientRect().height)
|
||||
await menu.locator('[data-effort-label]').click()
|
||||
expect(await slider.inputValue()).toBe('0')
|
||||
const tagHit = await menu.locator('[data-effort-tag]').evaluate((tag) => {
|
||||
const caption = tag.querySelector<HTMLElement>('[data-effort-caption]')!
|
||||
const bounds = tag.getBoundingClientRect()
|
||||
const x = bounds.left + bounds.width / 2
|
||||
const y = bounds.bottom - 1
|
||||
return {
|
||||
x, y, hitsCaption: document.elementFromPoint(x, y) === caption,
|
||||
tagScrollWidth: tag.scrollWidth, tagClientWidth: tag.clientWidth,
|
||||
captionScrollWidth: caption.scrollWidth, captionClientWidth: caption.clientWidth,
|
||||
}
|
||||
})
|
||||
expect(tagHit.hitsCaption).toBe(true)
|
||||
await trigger.focus()
|
||||
await page.mouse.click(tagHit.x, tagHit.y)
|
||||
expect(await slider.inputValue()).toBe('0')
|
||||
expect(await slider.evaluate(element => element === document.activeElement)).toBe(true)
|
||||
expect(requests).toBe(0)
|
||||
expect(tagHit.tagScrollWidth).toBe(tagHit.tagClientWidth)
|
||||
expect(tagHit.captionScrollWidth).toBe(tagHit.captionClientWidth)
|
||||
await info.click()
|
||||
const tooltip = page.getByRole('tooltip')
|
||||
await tooltip.waitFor()
|
||||
|
||||
@@ -20,12 +20,15 @@
|
||||
grid-row: 2;
|
||||
container-type: inline-size;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
pointer-events: none;
|
||||
height: 28px;
|
||||
margin: 8px 8px 0;
|
||||
}
|
||||
|
||||
.value {
|
||||
position: absolute;
|
||||
pointer-events: auto;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: max-content;
|
||||
@@ -33,15 +36,9 @@
|
||||
translate: clamp(0px, calc(var(--effort-thumb-size) / 2 + (100cqw - var(--effort-thumb-size)) * var(--dsh-effort-position) - 50%), calc(100cqw - 100%)) 0;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
box-sizing: border-box;
|
||||
max-width: 100%;
|
||||
height: 28px;
|
||||
padding: 1px 8px;
|
||||
border: 1px solid color-mix(in srgb, var(--dsw-alias-state-business-primary) 45%, transparent);
|
||||
border-radius: 999px;
|
||||
corner-shape: round;
|
||||
background: color-mix(in srgb, var(--dsw-alias-state-business-primary) 8%, var(--dsw-alias-bg-module-platform));
|
||||
color: var(--dsw-alias-state-business-primary);
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
@@ -53,20 +50,23 @@
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.value:has(.infoButton) {
|
||||
gap: 2px;
|
||||
padding-inline-end: 1px;
|
||||
.value:has(.infoButton) .caption {
|
||||
padding-inline-end: 27px;
|
||||
}
|
||||
|
||||
.caption {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
min-width: 0;
|
||||
height: 24px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
width: 100%;
|
||||
height: 28px;
|
||||
padding: 1px 8px;
|
||||
border: 1px solid color-mix(in srgb, var(--dsw-alias-state-business-primary) 45%, transparent);
|
||||
border-radius: 999px;
|
||||
corner-shape: round;
|
||||
background: color-mix(in srgb, var(--dsw-alias-state-business-primary) 8%, var(--dsw-alias-bg-module-platform));
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
white-space: inherit;
|
||||
@@ -79,7 +79,6 @@
|
||||
.caption:focus-visible {
|
||||
outline: 2px solid currentColor;
|
||||
outline-offset: 1px;
|
||||
border-radius: var(--dsw-radius-sm);
|
||||
}
|
||||
|
||||
.caption[aria-disabled='true'] {
|
||||
@@ -113,8 +112,11 @@
|
||||
}
|
||||
|
||||
.infoButton {
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
right: 2px;
|
||||
z-index: 1;
|
||||
display: inline-flex;
|
||||
flex: 0 0 24px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 24px;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// @vitest-environment jsdom
|
||||
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { afterEach, expect, it, vi } from 'vitest'
|
||||
import type { ComponentProps } from 'react'
|
||||
import { EffortSlider, type EffortSliderProps } from '../src/client/EffortSlider.tsx'
|
||||
|
||||
afterEach(() => { cleanup(); vi.restoreAllMocks(); vi.unstubAllGlobals() })
|
||||
|
||||
function setup(value: string | null = 'off', includeDefault = false, parentKey?: ReturnType<typeof vi.fn>) {
|
||||
function setup(value: string | null = 'off', includeDefault = false, parentKey?: ComponentProps<'div'>['onKeyDown']) {
|
||||
vi.stubGlobal('matchMedia', (query: string) => ({
|
||||
matches: query.includes('hover: hover'), media: query, onchange: null,
|
||||
addEventListener: vi.fn(), removeEventListener: vi.fn(), addListener: vi.fn(), removeListener: vi.fn(), dispatchEvent: () => true,
|
||||
|
||||
Reference in new issue
Block a user