Skip to content

Commit

Permalink
fix: ssr & touch
Browse files Browse the repository at this point in the history
  • Loading branch information
jer3m01 committed Oct 31, 2023
1 parent 2d7f7a3 commit 3c582f1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions apps/docs/src/routes/docs/core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ const CORE_NAV_SECTIONS: NavSection[] = [
title: "Link",
href: "/docs/core/components/link",
},
{
title: "Menubar",
href: "/docs/core/components/menubar",
status: "new",
},
{
title: "Pagination",
href: "/docs/core/components/pagination",
Expand Down
3 changes: 1 addition & 2 deletions packages/core/dev/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export default function App() {
return <>
</>;
return <></>;
}
3 changes: 0 additions & 3 deletions packages/core/src/menu/menu-trigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ export function MenuTrigger(props: MenuTriggerProps) {
callHandler(e, local.onClick);

if (!local.disabled) {
// When opened by click, automatically focus Menubar menus
optionalMenubarContext?.setAutoFocusMenu(true);

if (e.currentTarget.dataset.pointerType === "touch") context.toggle(true);
}
};
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/menubar/menubar-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
onCleanup,
splitProps,
} from "solid-js";
import { isServer } from "solid-js/web";

import { AsChildProp, Polymorphic } from "../polymorphic";
import { createControllableSignal, createInteractOutside } from "../primitives";
Expand Down Expand Up @@ -167,6 +168,7 @@ export function MenubarRoot(props: MenubarRootProps) {
};

createEffect(() => {
if (isServer) return;
if (local.focusOnAlt) window.addEventListener("keydown", keydownHandler);
else window.removeEventListener("keydown", keydownHandler);
});
Expand All @@ -176,6 +178,7 @@ export function MenubarRoot(props: MenubarRootProps) {
});

onCleanup(() => {
if (isServer) return;
window.removeEventListener("keydown", keydownHandler);
});

Expand Down

0 comments on commit 3c582f1

Please sign in to comment.