A: fix missolved path
This commit is contained in:
parent
e3d9d0c4ba
commit
5be56bb80e
1 changed files with 6 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
||||||
import { type JSX } from "solid-js";
|
import { splitProps, type JSX } from "solid-js";
|
||||||
import { useNavigator } from "./StackedRouter";
|
import { useNavigator } from "./StackedRouter";
|
||||||
|
import { useResolvedPath } from "@solidjs/router";
|
||||||
|
|
||||||
function handleClick(
|
function handleClick(
|
||||||
push: (name: string, state: unknown) => void,
|
push: (name: string, state: unknown) => void,
|
||||||
|
@ -7,13 +8,14 @@ function handleClick(
|
||||||
) {
|
) {
|
||||||
const target = event.currentTarget;
|
const target = event.currentTarget;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
|
||||||
push(target.href, { state: target.getAttribute("state") || undefined });
|
push(target.href, { state: target.getAttribute("state") || undefined });
|
||||||
}
|
}
|
||||||
|
|
||||||
const A = (oprops: JSX.HTMLElementTags["a"]) => {
|
const A = (oprops: Omit<JSX.HTMLElementTags["a"], "onClick" | "onclick">) => {
|
||||||
|
const [props, rest] = splitProps(oprops, ["href"]);
|
||||||
|
const resolvedPath = useResolvedPath(() => props.href || "#");
|
||||||
const { push } = useNavigator();
|
const { push } = useNavigator();
|
||||||
return <a onClick={[handleClick, push]} {...oprops}></a>;
|
return <a onClick={[handleClick, push]} href={resolvedPath()} {...rest}></a>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default A;
|
export default A;
|
||||||
|
|
Loading…
Reference in a new issue