Skip to content

Commit

Permalink
[sparkle] default container to dialog if it exists (#10936)
Browse files Browse the repository at this point in the history
* default container to dialog if it exists

* bump

* Target sheets as deefault portal container

* fixed default
  • Loading branch information
tdraier authored Feb 19, 2025
1 parent 5335486 commit abf71d1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions sparkle/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sparkle/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dust-tt/sparkle",
"version": "0.2.408",
"version": "0.2.409",
"scripts": {
"build": "rm -rf dist && npm run tailwind && npm run build:esm && npm run build:cjs",
"tailwind": "tailwindcss -i ./src/styles/tailwind.css -o dist/sparkle.css",
Expand Down
10 changes: 9 additions & 1 deletion sparkle/src/components/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,16 @@ const PopoverContent = React.forwardRef<
/>
);

const dialogElements = document.querySelectorAll(
".s-sheet[role=dialog][data-state=open]"
);

const defaultContainer = dialogElements[dialogElements.length - 1];

return mountPortal ? (
<PopoverPrimitive.Portal container={mountPortalContainer}>
<PopoverPrimitive.Portal
container={mountPortalContainer || defaultContainer}
>
{content}
</PopoverPrimitive.Portal>
) : (
Expand Down
2 changes: 1 addition & 1 deletion sparkle/src/components/Sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const SheetContent = React.forwardRef<
<FocusScope trapped={trapFocusScope} asChild>
<SheetPrimitive.Content
ref={ref}
className={cn(sheetVariants({ size, side }), className)}
className={cn(sheetVariants({ size, side }), className, "s-sheet")}
{...props}
>
{children}
Expand Down

0 comments on commit abf71d1

Please sign in to comment.