Skip to content

Commit 85156e3

Browse files
authored
chore: make useLandmark controller unstable (#7871)
* chore: make useLandmark controller unstable * remove from mono package * fix tests
1 parent 6fc6075 commit 85156e3

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

packages/@react-aria/landmark/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
*/
1212

1313
export type {AriaLandmarkRole, AriaLandmarkProps, LandmarkAria, LandmarkController} from './useLandmark';
14-
export {useLandmark, createLandmarkController} from './useLandmark';
14+
export {useLandmark, UNSTABLE_createLandmarkController} from './useLandmark';

packages/@react-aria/landmark/src/useLandmark.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ class LandmarkManager implements LandmarkManagerApi {
436436
}
437437

438438
/** Creates a LandmarkController, which allows programmatic navigation of landmarks. */
439-
export function createLandmarkController(): LandmarkController {
439+
export function UNSTABLE_createLandmarkController(): LandmarkController {
440440
// Get the current landmark manager and create a controller using it.
441441
let instance: LandmarkManagerApi | null = getLandmarkManager();
442442
let controller = instance?.createLandmarkController();

packages/@react-aria/landmark/stories/Landmark.stories.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ import {ActionGroup, Item} from '@react-spectrum/actiongroup';
1414
import {Cell, Column, Row, TableBody, TableHeader, TableView} from '@react-spectrum/table';
1515
import {Checkbox} from '@react-spectrum/checkbox';
1616
import {classNames, useFocusableRef, useStyleProps} from '@react-spectrum/utils';
17-
import {createLandmarkController, useLandmark} from '../';
1817
import {Flex} from '@react-spectrum/layout';
1918
import {Link} from '@react-spectrum/link';
2019
import {Meta} from '@storybook/react';
2120
import React, {SyntheticEvent, useEffect, useMemo, useRef} from 'react';
2221
import {SearchField} from '@react-spectrum/searchfield';
2322
import styles from './index.css';
2423
import {TextField} from '@react-spectrum/textfield';
24+
import {UNSTABLE_createLandmarkController, useLandmark} from '../';
2525

2626
interface StoryProps {}
2727

@@ -314,7 +314,7 @@ function ApplicationExample() {
314314
}
315315

316316
function IframeExample() {
317-
let controller = useMemo(() => createLandmarkController(), []);
317+
let controller = useMemo(() => UNSTABLE_createLandmarkController(), []);
318318
useEffect(() => () => controller.dispose(), [controller]);
319319
let onLoad = (e: SyntheticEvent) => {
320320
let iframe = e.target as HTMLIFrameElement;

packages/@react-aria/landmark/test/useLandmark.test.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import {ActionGroup, Item} from '@react-spectrum/actiongroup';
1515
import {Button} from '@react-spectrum/button';
1616
import {Cell, Column, Row, TableBody, TableHeader, TableView} from '@react-spectrum/table';
1717
import {Checkbox} from '@react-spectrum/checkbox';
18-
import {createLandmarkController, useLandmark} from '../';
1918
import {Provider} from '@react-spectrum/provider';
2019
import React from 'react';
2120
import {TextField} from '@react-spectrum/textfield';
2221
import {theme} from '@react-spectrum/theme-default';
22+
import {UNSTABLE_createLandmarkController, useLandmark} from '../';
2323
import {useFocusableRef} from '@react-spectrum/utils';
2424
import userEvent from '@testing-library/user-event';
2525

@@ -1214,7 +1214,7 @@ describe('LandmarkManager', function () {
12141214
await user.keyboard('{F6}');
12151215
expect(onLandmarkNavigation).not.toHaveBeenCalled();
12161216

1217-
let controller = createLandmarkController();
1217+
let controller = UNSTABLE_createLandmarkController();
12181218

12191219
await user.keyboard('{F6}');
12201220
expect(onLandmarkNavigation).toHaveBeenCalledTimes(1);
@@ -1247,7 +1247,7 @@ describe('LandmarkManager', function () {
12471247
await user.tab();
12481248
expect(document.activeElement).toBe(tree.getAllByRole('link')[0]);
12491249

1250-
let controller = createLandmarkController();
1250+
let controller = UNSTABLE_createLandmarkController();
12511251

12521252
act(() => {controller.focusNext();});
12531253
expect(document.activeElement).toBe(tree.getByRole('main'));
@@ -1276,7 +1276,7 @@ describe('LandmarkManager', function () {
12761276

12771277
act(() => tree.getByRole('textbox').focus());
12781278

1279-
let controller = createLandmarkController();
1279+
let controller = UNSTABLE_createLandmarkController();
12801280

12811281
act(() => {controller.focusPrevious();});
12821282
expect(document.activeElement).toBe(tree.getByRole('navigation'));
@@ -1305,7 +1305,7 @@ describe('LandmarkManager', function () {
13051305

13061306
act(() => tree.getByRole('textbox').focus());
13071307

1308-
let controller = createLandmarkController();
1308+
let controller = UNSTABLE_createLandmarkController();
13091309

13101310
act(() => {controller.focusMain();});
13111311
expect(document.activeElement).toBe(tree.getByRole('main'));
@@ -1317,7 +1317,7 @@ describe('LandmarkManager', function () {
13171317
describe('singleton', function () {
13181318
it('should store the landmark manager on the document', function () {
13191319
// ensure a manager exists.
1320-
let controller = createLandmarkController();
1320+
let controller = UNSTABLE_createLandmarkController();
13211321
let manager = document[Symbol.for('react-aria-landmark-manager')];
13221322
expect(manager).toBeDefined();
13231323
expect(typeof manager.version).toBe('number');
@@ -1335,7 +1335,7 @@ describe('LandmarkManager', function () {
13351335
</div>
13361336
);
13371337

1338-
let controller = createLandmarkController();
1338+
let controller = UNSTABLE_createLandmarkController();
13391339
let newController = {
13401340
navigate: jest.fn(),
13411341
focusNext: jest.fn(),

packages/@react-spectrum/toast/stories/Toast.stories.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ import {ActionButton, Button} from '@react-spectrum/button';
1515
import {ButtonGroup} from '@react-spectrum/buttongroup';
1616
import {Checkbox} from '@react-spectrum/checkbox';
1717
import {Content} from '@react-spectrum/view';
18-
import {createLandmarkController, useLandmark} from '@react-aria/landmark';
1918
import {Dialog, DialogTrigger} from '@react-spectrum/dialog';
2019
import {Flex} from '@react-spectrum/layout';
2120
import {Heading} from '@react-spectrum/text';
2221
import React, {SyntheticEvent, useEffect, useMemo, useRef, useState} from 'react';
2322
import {SpectrumToastOptions, ToastPlacement} from '../src/ToastContainer';
2423
import {ToastContainer, ToastQueue} from '../';
24+
import {UNSTABLE_createLandmarkController, useLandmark} from '@react-aria/landmark';
2525
import {UNSTABLE_PortalProvider} from '@react-aria/overlays';
2626

2727
export default {
@@ -260,7 +260,7 @@ function MultipleInner() {
260260
}
261261

262262
function IframeExample() {
263-
let controller = useMemo(() => createLandmarkController(), []);
263+
let controller = useMemo(() => UNSTABLE_createLandmarkController(), []);
264264
useEffect(() => () => controller.dispose(), [controller]);
265265
let onLoad = (e: SyntheticEvent) => {
266266
let iframe = e.target as HTMLIFrameElement;

packages/react-aria/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export {I18nProvider, useCollator, useDateFormatter, useFilter, useLocale, useLo
2525
export {useFocus, useFocusVisible, useFocusWithin, useHover, useInteractOutside, useKeyboard, useMove, usePress, useLongPress, useFocusable, Pressable, Focusable} from '@react-aria/interactions';
2626
export {useField, useLabel} from '@react-aria/label';
2727
export {useGridList, useGridListItem, useGridListSelectionCheckbox} from '@react-aria/gridlist';
28-
export {useLandmark, createLandmarkController} from '@react-aria/landmark';
28+
export {useLandmark} from '@react-aria/landmark';
2929
export {useLink} from '@react-aria/link';
3030
export {useListBox, useListBoxSection, useOption} from '@react-aria/listbox';
3131
export {useMenu, useMenuItem, useMenuSection, useMenuTrigger, useSubmenuTrigger} from '@react-aria/menu';

0 commit comments

Comments
 (0)