feat(routing): pass the new url to pageChange event
This commit is contained in:
parent
6f89e4a3e1
commit
9947970f63
2 changed files with 8 additions and 11 deletions
12
frontend/src/@types/dom.d.ts
vendored
12
frontend/src/@types/dom.d.ts
vendored
|
|
@ -1,19 +1,15 @@
|
||||||
import { type State } from "ft_state";
|
import { type State } from "ft_state";
|
||||||
|
|
||||||
interface CustomEventMap {
|
interface CustomEventMap {
|
||||||
"ft:pageChange": CustomEvent<{}>;
|
"ft:pageChange": CustomEvent<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Document {
|
interface Document {
|
||||||
//adds definition to Document, but you can do the same with HTMLElement
|
//adds definition to Document, but you can do the same with HTMLElement
|
||||||
addEventListener<K extends keyof CustomEventMap>(
|
addEventListener<K extends keyof CustomEventMap>(type: K,
|
||||||
type: K,
|
listener: (this: Document, ev: CustomEventMap[K]) => void): void;
|
||||||
listener: (this: Document, ev: CustomEventMap[K]) => void,
|
dispatchEvent<K extends keyof CustomEventMap>(ev: CustomEventMap[K]): void;
|
||||||
): void;
|
|
||||||
dispatchEvent<K extends keyof CustomEventMap>(
|
|
||||||
ev: CustomEventMap[K],
|
|
||||||
): void;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -205,9 +205,10 @@ export async function handleRoute() {
|
||||||
`/login?returnTo=${encodeURIComponent(window.location.pathname)}`,
|
`/login?returnTo=${encodeURIComponent(window.location.pathname)}`,
|
||||||
);
|
);
|
||||||
const app = document.getElementById("app")!;
|
const app = document.getElementById("app")!;
|
||||||
document.dispatchEvent(
|
|
||||||
new CustomEvent("ft:pageChange" as any, {} as any) as any,
|
const event = new CustomEvent("ft:pageChange", { detail: window.location.pathname });
|
||||||
);
|
document.dispatchEvent(event);
|
||||||
|
|
||||||
let ret = await executeRouteHandler(
|
let ret = await executeRouteHandler(
|
||||||
route_handler,
|
route_handler,
|
||||||
window.location.pathname,
|
window.location.pathname,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue