Skip to content

Commit aae1997

Browse files
committed
PR suggestions
1 parent 319c017 commit aae1997

File tree

11 files changed

+19
-26
lines changed

11 files changed

+19
-26
lines changed

packages/react-popover/src/components/Popover/usePopover.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const usePopover = (props: PopoverProps, defaultProps?: PopoverProps): Po
3636

3737
const { targetDocument } = useFluent();
3838
useOnClickOutside({
39-
contains: (parent, target) => elementContains(parent, target),
39+
contains: elementContains,
4040
element: targetDocument,
4141
callback: ev => state.setOpen(ev, false),
4242
refs: [state.triggerRef, state.contentRef],

packages/react-portal/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,12 @@ DOM output:
132132
<body>
133133
<div>
134134
{/* Virtual parent for outer portal*/}
135-
<span aria-hidden>
136-
{/* Virtual parent for inner portal*/}
137-
<span aria-hidden />
138-
</span>
135+
<span aria-hidden></span>
139136
</div>
140137

141138
<div id="portal-1" class="theme-provider-0">
139+
{/* Virtual parent for inner portal*/}
140+
<span aria-hidden />
142141
{children}
143142
</div>
144143
<div id="portal-2" class="theme-provider-0">

packages/react-portal/Spec.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,12 @@ DOM output:
208208
<body>
209209
<div>
210210
{/* Virtual parent for outer portal*/}
211-
<span aria-hidden>
212-
{/* Virtual parent for inner portal*/}
213-
<span aria-hidden />
214-
</span>
211+
<span aria-hidden></span>
215212
</div>
216213

217214
<div id="portal-1" class="theme-provider-0">
215+
{/* Virtual parent for inner portal*/}
216+
<span aria-hidden />
218217
{children}
219218
</div>
220219
<div id="portal-2" class="theme-provider-0">

packages/react-portal/src/components/Portal/Portal-node.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('Portal (node)', () => {
1919

2020
expect(component.toJSON()).toMatchInlineSnapshot(`
2121
<span
22-
aria-hidden={true}
22+
hidden={true}
2323
/>
2424
`);
2525
});

packages/react-portal/src/components/Portal/renderPortal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { PortalState } from './Portal.types';
77
*/
88
export const renderPortal = (state: PortalState): React.ReactElement => {
99
return (
10-
<span aria-hidden ref={state.virtualParentRootRef}>
10+
<span hidden ref={state.virtualParentRootRef}>
1111
{state.shouldRender && state.mountNode && ReactDOM.createPortal(state.children, state.mountNode)}
1212
</span>
1313
);

packages/react-portal/src/virtualParent/getParent.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ import { getVirtualParent } from './getVirtualParent';
22

33
/**
44
* Gets the element which is the parent of a given element.
5-
* If `allowVirtuaParents` is `true`, this method prefers the virtual parent over
6-
* real DOM parent when present.
5+
* This method prefers the virtual parent over real DOM parent when present.
76
*/
8-
export function getParent(child: HTMLElement, allowVirtualParents: boolean = true): HTMLElement | null {
9-
return (
10-
child &&
11-
((allowVirtualParents && getVirtualParent(child)) || (child.parentNode && (child.parentNode as HTMLElement)))
12-
);
7+
export function getParent(child: HTMLElement | null): HTMLElement | null {
8+
return (child && getVirtualParent(child)) || (child?.parentNode as HTMLElement | null);
139
}

packages/react-portal/src/virtualParent/getVirtualParent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { isVirtualElement } from './isVirtualElement';
44
*/
55
export function getVirtualParent(child: HTMLElement): HTMLElement | undefined {
66
let parent: HTMLElement | undefined;
7-
if (child && isVirtualElement(child)) {
7+
if (isVirtualElement(child)) {
88
parent = child._virtual.parent;
99
}
1010
return parent;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export * from './elementContains';
2-
export * from './setVirtualParent';
3-
export * from './isVirtualElement';
42
export * from './getParent';
53
export * from './getVirtualParent';
4+
export * from './isVirtualElement';
5+
export * from './setVirtualParent';

packages/react-portal/src/virtualParent/setVirtualParent.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ export function setVirtualParent(child: HTMLElement, parent?: HTMLElement): void
1212
}
1313

1414
const virtualChild = <VirtualElement>child;
15-
const virtualParent = <VirtualElement | null>parent;
1615

1716
if (!virtualChild._virtual) {
1817
virtualChild._virtual = {};
1918
}
2019

21-
virtualChild._virtual.parent = virtualParent || undefined;
20+
virtualChild._virtual.parent = parent || undefined;
2221
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export interface VirtualElement extends HTMLElement {
22
_virtual: {
3-
parent?: VirtualElement;
3+
parent?: HTMLElement;
44
};
55
}

packages/react-tooltip/src/components/Tooltip/__snapshots__/Tooltip.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ exports[`Tooltip renders a description tooltip content always 1`] = `
88
data-testid="the-target"
99
/>
1010
<span
11-
aria-hidden="true"
11+
hidden=""
1212
/>
1313
</div>
1414
<div
@@ -49,7 +49,7 @@ exports[`Tooltip renders the content of a nontrivial tooltip 1`] = `
4949
data-testid="the-target"
5050
/>
5151
<span
52-
aria-hidden="true"
52+
hidden=""
5353
/>
5454
</div>
5555
<div

0 commit comments

Comments
 (0)