Skip to content

Commit

Permalink
fix: #160
Browse files Browse the repository at this point in the history
  • Loading branch information
fabien-ml committed Mar 30, 2023
1 parent 80cc970 commit 8a1b75a
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 43 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-tables-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kobalte/core": patch
---

fix: #160
1 change: 1 addition & 0 deletions apps/docs/src/VERSIONS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const CORE_VERSIONS = [
"0.7.4",
"0.8.0",
"0.8.1",
"0.8.2",
].reverse();

export const LATEST_CORE_CHANGELOG_URL = `/docs/changelog/${CORE_VERSIONS[0].replaceAll(".", "-")}`;
Expand Down
7 changes: 7 additions & 0 deletions apps/docs/src/routes/docs/changelog/0-8-2.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# v0.8.2

**March 30, 2023**.

## Bug fixes

- [#160](https://github.com/kobaltedev/kobalte/pull/160)
3 changes: 1 addition & 2 deletions packages/core/src/dialog/dialog-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ export function DialogContent(props: DialogContentProps) {
role="dialog"
id={local.id}
tabIndex={-1}
isDismissed={!context.isOpen()}
disableOutsidePointerEvents={context.isOpen() && context.isModal()}
disableOutsidePointerEvents={context.isModal() && context.isOpen()}
excludedElements={[context.triggerRef]}
aria-labelledby={context.titleId()}
aria-describedby={context.descriptionId()}
Expand Down
62 changes: 27 additions & 35 deletions packages/core/src/dismissable-layer/dismissable-layer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/

import { contains, getDocument, mergeRefs, OverrideComponentProps } from "@kobalte/utils";
import { Accessor, createEffect, on, onCleanup, splitProps } from "solid-js";
import { Accessor, createEffect, on, onCleanup, onMount, splitProps } from "solid-js";

import { AsChildProp, Polymorphic } from "../polymorphic";
import {
Expand All @@ -31,9 +31,6 @@ import {
import { layerStack } from "./layer-stack";

export interface DismissableLayerOptions extends AsChildProp {
/** Whether the layer is considered dismissed, regardless if it is mounted or not. */
isDismissed: boolean;

/**
* When `true`, hover/focus/click interactions will be disabled on elements outside
* the layer. Users will need to click twice on outside elements to
Expand Down Expand Up @@ -83,7 +80,6 @@ export function DismissableLayer(props: DismissableLayerProps) {

const [local, others] = splitProps(props, [
"ref",
"isDismissed",
"disableOutsidePointerEvents",
"excludedElements",
"onEscapeKeyDown",
Expand Down Expand Up @@ -141,7 +137,6 @@ export function DismissableLayer(props: DismissableLayerProps) {

createInteractOutside(
{
isDisabled: () => local.isDismissed,
shouldExcludeElement,
onPointerDownOutside,
onFocusOutside,
Expand All @@ -150,7 +145,6 @@ export function DismissableLayer(props: DismissableLayerProps) {
);

createEscapeKeyDown({
isDisabled: () => local.isDismissed,
ownerDocument: () => getDocument(ref),
onEscapeKeyDown: e => {
if (!ref || !layerStack.isTopMostLayer(ref)) {
Expand All @@ -166,46 +160,44 @@ export function DismissableLayer(props: DismissableLayerProps) {
},
});

createEffect(
on([() => ref, () => local.isDismissed], ([ref, isDismissed]) => {
if (!ref || isDismissed) {
return;
}
onMount(() => {
if (!ref) {
return;
}

layerStack.addLayer({
node: ref,
isPointerBlocking: local.disableOutsidePointerEvents,
dismiss: local.onDismiss,
});
layerStack.addLayer({
node: ref,
isPointerBlocking: local.disableOutsidePointerEvents,
dismiss: local.onDismiss,
});

const unregisterFromParentLayer = parentContext?.registerNestedLayer(ref);
const unregisterFromParentLayer = parentContext?.registerNestedLayer(ref);

layerStack.assignPointerEventToLayers();
layerStack.assignPointerEventToLayers();

layerStack.disableBodyPointerEvents(ref);
layerStack.disableBodyPointerEvents(ref);

onCleanup(() => {
if (!ref) {
return;
}
onCleanup(() => {
if (!ref) {
return;
}

layerStack.removeLayer(ref);
layerStack.removeLayer(ref);

unregisterFromParentLayer?.();
unregisterFromParentLayer?.();

// Re-assign pointer event to remaining layers.
layerStack.assignPointerEventToLayers();
// Re-assign pointer event to remaining layers.
layerStack.assignPointerEventToLayers();

layerStack.restoreBodyPointerEvents(ref);
});
})
);
layerStack.restoreBodyPointerEvents(ref);
});
});

createEffect(
on(
[() => ref, () => local.isDismissed, () => local.disableOutsidePointerEvents],
([ref, isDismissed, disableOutsidePointerEvents]) => {
if (!ref || isDismissed) {
[() => ref, () => local.disableOutsidePointerEvents],
([ref, disableOutsidePointerEvents]) => {
if (!ref) {
return;
}

Expand Down
1 change: 0 additions & 1 deletion packages/core/src/hover-card/hover-card-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export function HoverCardContent(props: HoverCardContentProps) {
context.setContentRef(el);
context.contentPresence.setRef(el);
}, local.ref)}
isDismissed={!context.isOpen()}
disableOutsidePointerEvents={false}
style={{
"--kb-hovercard-content-transform-origin": "var(--kb-popper-content-transform-origin)",
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/menu/menu-content-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ export function MenuContentBase(props: MenuContentBaseProps) {
role="menu"
id={local.id}
tabIndex={selectableList.tabIndex()}
isDismissed={!context.isOpen()}
disableOutsidePointerEvents={isRootModalContent() && context.isOpen()}
excludedElements={[context.triggerRef]}
style={{
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/popover/popover-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ export function PopoverContent(props: PopoverContentProps) {
role="dialog"
id={local.id}
tabIndex={-1}
isDismissed={!context.isOpen()}
disableOutsidePointerEvents={context.isOpen() && context.isModal()}
disableOutsidePointerEvents={context.isModal() && context.isOpen()}
excludedElements={[context.triggerRef]}
style={{
"--kb-popover-content-transform-origin": "var(--kb-popper-content-transform-origin)",
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/select/select-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ export function SelectContent(props: SelectContentProps) {
context.contentPresence.setRef(el);
ref = el;
}, local.ref)}
isDismissed={!context.isOpen()}
disableOutsidePointerEvents={context.isOpen() && context.isModal()}
disableOutsidePointerEvents={context.isModal() && context.isOpen()}
excludedElements={[context.triggerRef]}
style={{
"--kb-select-content-transform-origin": "var(--kb-popper-content-transform-origin)",
Expand Down

0 comments on commit 8a1b75a

Please sign in to comment.