fix: complete submenu panel ARIA, focus and event passthrough
- Submenu panel name priority is explicit aria-label > menu content channel > this instance's trigger; an explicit label drops the id reference so it cannot be shadowed. - openAutoFocus and animationend chain with the caller's handlers like keydown and interact-outside, so caller callbacks run and can cancel. - The panel loop falls back to the menu-level shouldFocusWrap and is always passed as a boolean: an undefined -> true update is dropped by the base prop chain, so the menu policy never applied. - Add a jsdom CSSOM polyfill for CSS.escape via vitest setupFiles; the animationend test no longer raises an unhandled error.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* jsdom lacks parts of the CSSOM. Reka's Presence uses `CSS.escape` when it
|
||||
* resolves exiting children, so tests that dispatch real `animationend` events
|
||||
* need the same capability a browser provides. Only fills the gap; never
|
||||
* overrides an existing implementation.
|
||||
*/
|
||||
type CssEscapeHost = { escape?: (value: string) => string };
|
||||
const cssGlobal = globalThis as unknown as { CSS?: CssEscapeHost };
|
||||
|
||||
if (!cssGlobal.CSS) cssGlobal.CSS = {};
|
||||
|
||||
if (typeof cssGlobal.CSS.escape !== "function") {
|
||||
// Approximation of CSS.escape for selector fragments: hex-escape leading
|
||||
// digits and any character outside the identifier set.
|
||||
const escapeIdentifier = (value: string) => {
|
||||
const input = String(value);
|
||||
let output = "";
|
||||
for (let index = 0; index < input.length; index += 1) {
|
||||
const char = input[index];
|
||||
const code = char.codePointAt(0) ?? 0;
|
||||
const isFirst = index === 0;
|
||||
const digits = code >= 0x30 && code <= 0x39;
|
||||
const safe =
|
||||
code >= 0x80 ||
|
||||
code === 0x2d ||
|
||||
code === 0x5f ||
|
||||
(code >= 0x30 && code <= 0x39) ||
|
||||
(code >= 0x41 && code <= 0x5a) ||
|
||||
(code >= 0x61 && code <= 0x7a);
|
||||
if (code === 0) output += "\uFFFD";
|
||||
else if ((isFirst && digits) || !safe)
|
||||
output += `\\${code.toString(16)} `;
|
||||
else output += char;
|
||||
}
|
||||
return output;
|
||||
};
|
||||
cssGlobal.CSS.escape = escapeIdentifier;
|
||||
}
|
||||
Reference in New Issue
Block a user