Skip to content

Commit

Permalink
fix: scroll area display style (#863)
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte authored Nov 3, 2024
1 parent dccab59 commit d7ee925
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-hotels-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"bits-ui": patch
---

fix: dont use `display: table` in scroll area
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,13 @@
:global([data-scroll-area-viewport])::-webkit-scrollbar {
display: none !important;
}
:global(:where([data-scroll-area-viewport])) {
display: flex;
flex-direction: column;
align-items: stretch;
}
:global(:where([data-scroll-area-content])) {
flex-grow: 1;
}
</style>
15 changes: 10 additions & 5 deletions packages/bits-ui/src/lib/bits/scroll-area/scroll-area.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { useDebounce } from "runed";
import { untrack } from "svelte";
import { afterTick, box, executeCallbacks, useRefById } from "svelte-toolbelt";
import { box, executeCallbacks, useRefById } from "svelte-toolbelt";
import type { ScrollAreaType } from "./types.js";
import type { ReadableBoxedValues } from "$lib/internal/box.svelte.js";
import { addEventListener } from "$lib/internal/events.js";
Expand Down Expand Up @@ -136,10 +136,15 @@ class ScrollAreaViewportState {
() =>
({
id: this.#contentId.current,
style: {
minWidth: "100%",
display: "table",
},
"data-scroll-area-content": "",
/**
* When horizontal scrollbar is visible: this element should be at least
* as wide as its children for size calculations to work correctly.
*
* When horizontal scrollbar is NOT visible: this element's width should
* be constrained by the parent container to enable `text-overflow: ellipsis`
*/
style: { minWidth: this.root.scrollbarXEnabled ? "fit-content" : undefined },
}) as const
);
}
Expand Down

0 comments on commit d7ee925

Please sign in to comment.