mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
fix(desktop): scope wheel exemption to active terminal
Co-authored-by: npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@buzz.block.builderlab.xyz> Signed-off-by: npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@buzz.block.builderlab.xyz>
This commit is contained in:
parent
9d214237e6
commit
397855c9ab
@@ -2,7 +2,7 @@ import * as React from "react";
|
||||
|
||||
const BOUNDARY_EPSILON_PX = 1;
|
||||
const CONVERSATION_SCROLL_SELECTOR = "[data-buzz-conversation-scroll]";
|
||||
const TERMINAL_SUBSTRATE_SELECTOR = "[data-terminal-owner]";
|
||||
const TERMINAL_SUBSTRATE_SELECTOR = '[data-terminal-owner="terminal"]';
|
||||
const SCROLLABLE_OVERFLOW_VALUES = new Set(["auto", "scroll", "overlay"]);
|
||||
|
||||
function isHTMLElement(value: EventTarget | null): value is HTMLElement {
|
||||
|
||||
@@ -70,7 +70,7 @@ test("locks viewport rubber-band outside conversation scrollers", async ({
|
||||
// gesture alone so the substrate's own handler can receive it.
|
||||
await page.evaluate(() => {
|
||||
const terminal = document.createElement("section");
|
||||
terminal.dataset.terminalOwner = "buzz";
|
||||
terminal.dataset.terminalOwner = "terminal";
|
||||
terminal.dataset.testid = "terminal-wheel-target";
|
||||
document.body.append(terminal);
|
||||
});
|
||||
@@ -112,18 +112,43 @@ test("locks horizontal viewport pan everywhere", async ({ page }) => {
|
||||
|
||||
await page.evaluate(() => {
|
||||
const terminal = document.createElement("section");
|
||||
terminal.dataset.terminalOwner = "buzz";
|
||||
terminal.dataset.terminalOwner = "terminal";
|
||||
terminal.dataset.testid = "terminal-wheel-target";
|
||||
document.body.append(terminal);
|
||||
});
|
||||
for (const deltaX of [-120, 120]) {
|
||||
for (const [deltaX, deltaY, prevented] of [
|
||||
[120, 0, true],
|
||||
[0, 120, false],
|
||||
[120, 120, false],
|
||||
[120, 20, true],
|
||||
] as const) {
|
||||
await expect(
|
||||
dispatchWheelPrevented(page, '[data-testid="terminal-wheel-target"]', {
|
||||
deltaX,
|
||||
deltaY,
|
||||
}),
|
||||
).resolves.toBe(true);
|
||||
).resolves.toBe(prevented);
|
||||
}
|
||||
|
||||
// A concealed substrate is not an active custom wheel consumer. Keep dead
|
||||
// space locked even if a future layout places Buzz content inside it.
|
||||
await page.evaluate(() => {
|
||||
const terminal = document.querySelector<HTMLElement>(
|
||||
'[data-testid="terminal-wheel-target"]',
|
||||
);
|
||||
const buzzContent = document.createElement("div");
|
||||
buzzContent.dataset.testid = "concealed-terminal-dead-space";
|
||||
terminal?.append(buzzContent);
|
||||
if (terminal) terminal.dataset.terminalOwner = "buzz";
|
||||
});
|
||||
await expect(
|
||||
dispatchWheelPrevented(
|
||||
page,
|
||||
'[data-testid="concealed-terminal-dead-space"]',
|
||||
{ deltaY: 120 },
|
||||
),
|
||||
).resolves.toBe(true);
|
||||
|
||||
// A predominantly vertical gesture with slight horizontal drift still
|
||||
// reaches the conversation scroller.
|
||||
await expect(
|
||||
|
||||
Reference in New Issue
Block a user