Skip to content

Commit 5104261

Browse files
authored
fix(Multiple): ensure preventOverflowTextSelection prop is applied (#1435)
1 parent a9dd7c4 commit 5104261

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

.changeset/forty-parrots-agree.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"bits-ui": patch
3+
---
4+
5+
fix(Multiple): ensure `preventOverflowTextSelection` prop is applied

packages/bits-ui/src/lib/bits/utilities/text-selection-layer/text-selection-layer.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
1616
useTextSelectionLayer({
1717
id: box.with(() => id),
18-
preventOverflowTextSelection: box.with(() => preventOverflowTextSelection),
1918
onPointerDown: box.with(() => onPointerDown),
2019
onPointerUp: box.with(() => onPointerUp),
21-
enabled: box.with(() => enabled),
20+
enabled: box.with(() => enabled && preventOverflowTextSelection),
2221
});
2322
</script>
2423

packages/bits-ui/src/lib/bits/utilities/text-selection-layer/use-text-selection-layer.svelte.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ import { noop } from "$lib/internal/noop.js";
1313
import { isHTMLElement } from "$lib/internal/is.js";
1414
import { isOrContainsTarget } from "$lib/internal/elements.js";
1515

16-
type StateProps = ReadableBoxedValues<Required<Omit<TextSelectionLayerImplProps, "children">>>;
16+
type TextSelectionLayerStateProps = ReadableBoxedValues<
17+
Required<Omit<TextSelectionLayerImplProps, "children" | "preventOverflowTextSelection">>
18+
>;
1719

1820
globalThis.bitsTextSelectionLayers ??= new Map<TextSelectionLayerState, ReadableBox<boolean>>();
1921

2022
export class TextSelectionLayerState {
2123
#unsubSelectionLock = noop;
2224
#ref = box<HTMLElement | null>(null);
2325

24-
constructor(readonly opts: StateProps) {
26+
constructor(readonly opts: TextSelectionLayerStateProps) {
2527
useRefById({
2628
id: opts.id,
2729
ref: this.#ref,
@@ -79,7 +81,7 @@ export class TextSelectionLayerState {
7981
};
8082
}
8183

82-
export function useTextSelectionLayer(props: StateProps) {
84+
export function useTextSelectionLayer(props: TextSelectionLayerStateProps) {
8385
return new TextSelectionLayerState(props);
8486
}
8587

0 commit comments

Comments
 (0)