Skip to content

Commit c644fea

Browse files
authored
[internal] Remove unused options (#4036)
1 parent 16f34b1 commit c644fea

23 files changed

+59
-475
lines changed

packages/react/src/floating-ui-react/components/FloatingDelayGroup.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ export function FloatingDelayGroup(props: FloatingDelayGroupProps): React.JSX.El
8989
}
9090

9191
interface UseDelayGroupOptions {
92-
/**
93-
* Whether delay grouping should be enabled.
94-
* @default true
95-
*/
96-
enabled?: boolean | undefined;
9792
/**
9893
* Whether the trigger this hook is used in has opened the tooltip.
9994
*/
@@ -127,7 +122,7 @@ export function useDelayGroup(
127122
): UseDelayGroupReturn {
128123
const store = 'rootStore' in context ? context.rootStore : context;
129124
const floatingId = store.useState('floatingId');
130-
const { enabled = true, open } = options;
125+
const { open } = options;
131126

132127
const groupContext = React.useContext(FloatingDelayGroupContext);
133128
const {
@@ -151,9 +146,6 @@ export function useDelayGroup(
151146
delayRef.current = initialDelayRef.current;
152147
}
153148

154-
if (!enabled) {
155-
return undefined;
156-
}
157149
if (!currentIdRef.current) {
158150
return undefined;
159151
}
@@ -182,7 +174,6 @@ export function useDelayGroup(
182174
}
183175
return undefined;
184176
}, [
185-
enabled,
186177
open,
187178
floatingId,
188179
currentIdRef,
@@ -195,9 +186,6 @@ export function useDelayGroup(
195186
]);
196187

197188
useIsoLayoutEffect(() => {
198-
if (!enabled) {
199-
return;
200-
}
201189
if (!open) {
202190
return;
203191
}
@@ -224,7 +212,6 @@ export function useDelayGroup(
224212
prevContext?.setIsInstantPhase(false);
225213
}
226214
}, [
227-
enabled,
228215
open,
229216
floatingId,
230217
store,

packages/react/src/floating-ui-react/components/FloatingFocusManager.test.tsx

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -761,19 +761,6 @@ describe.skipIf(!isJSDOM)('FloatingFocusManager', () => {
761761
expect(screen.getByTestId('last')).toHaveFocus();
762762
});
763763

764-
test('false — shift tabbing does not trap focus when reference is in order', async () => {
765-
render(<App modal={false} order={['reference', 'content']} />);
766-
767-
fireEvent.click(screen.getByTestId('reference'));
768-
await flushMicrotasks();
769-
770-
await userEvent.tab();
771-
await userEvent.tab({ shift: true });
772-
await userEvent.tab({ shift: true });
773-
774-
expect(screen.getByRole('dialog')).toBeInTheDocument();
775-
});
776-
777764
test('false - comboboxes do not hide all other nodes', async () => {
778765
function App() {
779766
const [open, setOpen] = React.useState(false);
@@ -1751,48 +1738,6 @@ describe.skipIf(!isJSDOM)('FloatingFocusManager', () => {
17511738
expect(screen.getByText('outside')).toHaveAttribute('aria-hidden', 'true');
17521739
});
17531740

1754-
describe('getInsideElements', () => {
1755-
test('returns a list of elements that should be considered part of the floating element', async () => {
1756-
function App() {
1757-
const [isOpen, setIsOpen] = React.useState(false);
1758-
1759-
const { refs, context } = useFloating({
1760-
open: isOpen,
1761-
onOpenChange: setIsOpen,
1762-
});
1763-
1764-
const click = useClick(context);
1765-
1766-
const { getReferenceProps, getFloatingProps } = useInteractions([click]);
1767-
1768-
return (
1769-
<>
1770-
<button ref={refs.setReference} {...getReferenceProps()} data-testid="reference" />
1771-
<div data-testid="inside" />
1772-
{isOpen && (
1773-
<FloatingFocusManager
1774-
context={context}
1775-
getInsideElements={() => {
1776-
const inside = document.querySelector<HTMLElement>('[data-testid="inside"]');
1777-
return inside ? [inside] : [];
1778-
}}
1779-
>
1780-
<div ref={refs.setFloating} data-testid="floating" {...getFloatingProps()} />
1781-
</FloatingFocusManager>
1782-
)}
1783-
</>
1784-
);
1785-
}
1786-
1787-
render(<App />);
1788-
1789-
await userEvent.click(screen.getByTestId('reference'));
1790-
await flushMicrotasks();
1791-
1792-
expect(screen.getByTestId('inside')).not.toHaveAttribute('data-base-ui-inert');
1793-
});
1794-
});
1795-
17961741
test('floating element with no focusable elements and no listbox role gets tabIndex=0 when initialFocus is -1', async () => {
17971742
function App() {
17981743
const [isOpen, setIsOpen] = React.useState(false);

packages/react/src/floating-ui-react/components/FloatingFocusManager.tsx

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,6 @@ export interface FloatingFocusManagerProps {
167167
* @default false
168168
*/
169169
disabled?: boolean | undefined;
170-
/**
171-
* The order in which focus cycles.
172-
* @default ['content']
173-
*/
174-
order?: Array<'reference' | 'floating' | 'content'> | undefined;
175170
/**
176171
* Determines the element to focus when the floating element is opened.
177172
*
@@ -234,11 +229,6 @@ export interface FloatingFocusManagerProps {
234229
* @default true
235230
*/
236231
closeOnFocusOut?: boolean | undefined;
237-
/**
238-
* Returns a list of elements that should be considered part of the
239-
* floating element.
240-
*/
241-
getInsideElements?: (() => Element[]) | undefined;
242232
/**
243233
* Overrides the element to focus when tabbing forward out of the floating element.
244234
*/
@@ -268,14 +258,12 @@ export function FloatingFocusManager(props: FloatingFocusManagerProps): React.JS
268258
context,
269259
children,
270260
disabled = false,
271-
order = ['content'],
272261
initialFocus = true,
273262
returnFocus = true,
274263
restoreFocus = false,
275264
modal = true,
276265
closeOnFocusOut = true,
277266
openInteractionType = '',
278-
getInsideElements: getInsideElementsProp = () => [],
279267
nextFocusableElement,
280268
previousFocusableElement,
281269
beforeContentFocusGuardRef,
@@ -290,7 +278,6 @@ export function FloatingFocusManager(props: FloatingFocusManagerProps): React.JS
290278
const { events, dataRef } = store.context;
291279

292280
const getNodeId = useStableCallback(() => dataRef.current.floatingContext?.nodeId);
293-
const getInsideElements = useStableCallback(getInsideElementsProp);
294281

295282
const ignoreInitialFocus = initialFocus === false;
296283
// If the reference is a combobox and is typeable (e.g. input/textarea),
@@ -300,7 +287,7 @@ export function FloatingFocusManager(props: FloatingFocusManagerProps): React.JS
300287
// start.
301288
const isUntrappedTypeableCombobox = isTypeableCombobox(domReference) && ignoreInitialFocus;
302289

303-
const orderRef = useValueAsRef(order);
290+
const orderRef = React.useRef<Array<'reference' | 'floating' | 'content'>>(['content']);
304291
const initialFocusRef = useValueAsRef(initialFocus);
305292
const returnFocusRef = useValueAsRef(returnFocus);
306293
const openInteractionTypeRef = useValueAsRef(openInteractionType);
@@ -658,7 +645,6 @@ export function FloatingFocusManager(props: FloatingFocusManagerProps): React.JS
658645
floating,
659646
rootAncestorComboboxDomReference,
660647
...portalNodes,
661-
...getInsideElements(),
662648
startDismissButtonRef.current,
663649
endDismissButtonRef.current,
664650
beforeGuardRef.current,
@@ -682,7 +668,6 @@ export function FloatingFocusManager(props: FloatingFocusManagerProps): React.JS
682668
isUntrappedTypeableCombobox,
683669
tree,
684670
getNodeId,
685-
getInsideElements,
686671
nextFocusableElement,
687672
previousFocusableElement,
688673
]);

packages/react/src/floating-ui-react/components/FloatingPortal.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export interface UseFloatingPortalNodeProps {
5151
| undefined;
5252
componentProps?: useRenderElement.ComponentProps<any> | undefined;
5353
elementProps?: React.HTMLAttributes<HTMLDivElement> | undefined;
54-
elementState?: Record<string, unknown> | undefined;
5554
}
5655

5756
export interface UseFloatingPortalNodeResult {
@@ -62,13 +61,7 @@ export interface UseFloatingPortalNodeResult {
6261
export function useFloatingPortalNode(
6362
props: UseFloatingPortalNodeProps = {},
6463
): UseFloatingPortalNodeResult {
65-
const {
66-
ref,
67-
container: containerProp,
68-
componentProps = EMPTY_OBJECT,
69-
elementProps,
70-
elementState,
71-
} = props;
64+
const { ref, container: containerProp, componentProps = EMPTY_OBJECT, elementProps } = props;
7265

7366
const uniqueId = useId();
7467
const portalContext = usePortalContext();
@@ -128,7 +121,6 @@ export function useFloatingPortalNode(
128121

129122
const portalElement = useRenderElement('div', componentProps, {
130123
ref: [ref, setPortalNodeRef],
131-
state: elementState,
132124
props: [
133125
{
134126
id: uniqueId,

packages/react/src/floating-ui-react/hooks/useClientPoint.test.tsx

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ function expectLocation({ x, y }: Coords) {
1414

1515
function App({
1616
enabled = true,
17-
point,
1817
axis,
1918
useTriggerProps = false,
2019
}: {
2120
enabled?: boolean;
22-
point?: Coords;
2321
axis?: 'both' | 'x' | 'y';
2422
useTriggerProps?: boolean;
2523
}) {
@@ -30,7 +28,6 @@ function App({
3028
});
3129
const clientPoint = useClientPoint(context, {
3230
enabled,
33-
...point,
3431
axis,
3532
});
3633
const { getReferenceProps, getTriggerProps, getFloatingProps } = useInteractions([clientPoint]);
@@ -62,22 +59,6 @@ function App({
6259
);
6360
}
6461

65-
test('renders at explicit client point and can be updated', async () => {
66-
const { rerender } = render(<App point={{ x: 0, y: 0 }} />);
67-
68-
fireEvent.click(screen.getByRole('button'));
69-
70-
await flushMicrotasks();
71-
72-
expectLocation({ x: 0, y: 0 });
73-
74-
rerender(<App point={{ x: 1000, y: 1000 }} />);
75-
76-
await flushMicrotasks();
77-
78-
expectLocation({ x: 1000, y: 1000 });
79-
});
80-
8162
test('updates position from trigger props', async () => {
8263
render(<App useTriggerProps />);
8364

@@ -198,22 +179,6 @@ test('renders at mouse event coords', async () => {
198179
expectLocation({ x: 0, y: 0 });
199180
});
200181

201-
test('ignores mouse events when explicit coords are specified', async () => {
202-
render(<App point={{ x: 0, y: 0 }} />);
203-
204-
fireEvent(
205-
screen.getByTestId('reference'),
206-
new MouseEvent('mousemove', {
207-
bubbles: true,
208-
clientX: 500,
209-
clientY: 500,
210-
}),
211-
);
212-
await flushMicrotasks();
213-
214-
expectLocation({ x: 0, y: 0 });
215-
});
216-
217182
test('cleans up window listener when closing or disabling', async () => {
218183
const { rerender } = render(<App />);
219184

packages/react/src/floating-ui-react/hooks/useClientPoint.ts

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import * as React from 'react';
33
import { getWindow } from '@floating-ui/utils/dom';
44
import { useStableCallback } from '@base-ui/utils/useStableCallback';
5-
import { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';
65
import { contains, getTarget, isMouseLikePointerType } from '../utils';
76

87
import type { ContextData, ElementProps, FloatingContext, FloatingRootContext } from '../types';
@@ -99,16 +98,6 @@ export interface UseClientPointProps {
9998
* @default 'both'
10099
*/
101100
axis?: ('x' | 'y' | 'both') | undefined;
102-
/**
103-
* An explicitly defined `x` client coordinate.
104-
* @default null
105-
*/
106-
x?: (number | null) | undefined;
107-
/**
108-
* An explicitly defined `y` client coordinate.
109-
* @default null
110-
*/
111-
y?: (number | null) | undefined;
112101
}
113102

114103
/**
@@ -127,7 +116,7 @@ export function useClientPoint(
127116
const domReference = store.useState('domReferenceElement');
128117
const dataRef = store.context.dataRef;
129118

130-
const { enabled = true, axis = 'both', x = null, y = null } = props;
119+
const { enabled = true, axis = 'both' } = props;
131120

132121
const initialRef = React.useRef(false);
133122
const cleanupListenerRef = React.useRef<null | (() => void)>(null);
@@ -162,10 +151,6 @@ export function useClientPoint(
162151
);
163152

164153
const handleReferenceEnterOrMove = useStableCallback((event: React.MouseEvent<Element>) => {
165-
if (x != null || y != null) {
166-
return;
167-
}
168-
169154
if (!open) {
170155
setReference(event.clientX, event.clientY, event.currentTarget as Element);
171156
} else if (!cleanupListenerRef.current) {
@@ -183,8 +168,7 @@ export function useClientPoint(
183168
const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
184169

185170
const addListener = React.useCallback(() => {
186-
// Explicitly specified `x`/`y` coordinates shouldn't add a listener.
187-
if (!openCheck || !enabled || x != null || y != null) {
171+
if (!openCheck || !enabled) {
188172
return undefined;
189173
}
190174

@@ -213,7 +197,7 @@ export function useClientPoint(
213197

214198
store.set('positionReference', domReference);
215199
return undefined;
216-
}, [openCheck, enabled, x, y, floating, dataRef, domReference, store, setReference]);
200+
}, [openCheck, enabled, floating, dataRef, domReference, store, setReference]);
217201

218202
React.useEffect(() => {
219203
return addListener();
@@ -231,13 +215,6 @@ export function useClientPoint(
231215
}
232216
}, [enabled, open]);
233217

234-
useIsoLayoutEffect(() => {
235-
if (enabled && (x != null || y != null)) {
236-
initialRef.current = false;
237-
setReference(x, y);
238-
}
239-
}, [enabled, x, y, setReference]);
240-
241218
const reference: ElementProps['reference'] = React.useMemo(() => {
242219
function setPointerTypeRef(event: React.PointerEvent) {
243220
setPointerType(event.pointerType);

packages/react/src/floating-ui-react/hooks/useDismiss.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ describe.skipIf(!isJSDOM)('useDismiss', () => {
526526

527527
const popoverInteractions = useInteractions([useDismiss(popover.context)]);
528528
const tooltipInteractions = useInteractions([
529-
useFocus(tooltip.context, { visibleOnly: false }),
529+
useFocus(tooltip.context),
530530
useDismiss(tooltip.context),
531531
]);
532532

0 commit comments

Comments
 (0)