fix(licensing): simplify S08 and reveal linked stage without losing context
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
/** Reveal an existing stage without navigation, remounting fields or changing context. */
|
||||
export function revealPathStage(root: HTMLElement, hash: string, codes: string[]): boolean {
|
||||
const code = hash.startsWith("#") ? hash.slice(1) : "";
|
||||
if (!codes.includes(code)) return false;
|
||||
const target = root.ownerDocument.getElementById(code);
|
||||
if (!target || !root.contains(target)) return false;
|
||||
let current: HTMLElement | null = target;
|
||||
while (current && current !== root) {
|
||||
if (current.tagName === "DETAILS") (current as HTMLDetailsElement).open = true;
|
||||
current = current.parentElement;
|
||||
}
|
||||
target.scrollIntoView({ block: "start" });
|
||||
target.focus({ preventScroll: true });
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user