feat: implement onClickFocus helper

master
Katja Lutz 2 years ago
parent 9408e4d8ce
commit fe8cf85e2a

@ -1,5 +1,6 @@
import Big from "big.js";
import { fromUnixTime, intlFormat } from "date-fns";
import { JSX } from "solid-js";
export const sleep = (timeout: number) =>
new Promise((res) => setTimeout(res, timeout));
@ -65,3 +66,20 @@ export const shuffle = (list: any[]) => {
};
export const getHost = () => "https://rappli.ch";
export const onClickFocus: JSX.EventHandlerUnion<
HTMLAnchorElement,
MouseEvent
> = (evt) => {
const el = evt.currentTarget!;
const id = el.getAttribute("href");
if (id == null) {
return;
}
const targetEl = document.querySelector<HTMLElement>(id);
if (targetEl == null) {
return;
}
targetEl.focus();
};

Loading…
Cancel
Save