Skip to content

Commit

Permalink
skip initial rendering in portaled dropdown components
Browse files Browse the repository at this point in the history
  • Loading branch information
chaance committed Apr 20, 2022
1 parent dd2821b commit 0c21334
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/combobox/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ export const ComboboxPopover = React.forwardRef(
data-expanded={isExpanded || undefined}
position={position}
targetRef={inputRef}
unstable_skipInitialPortalRender
{...sharedProps}
/>
) : (
Expand All @@ -696,7 +697,8 @@ export const ComboboxPopover = React.forwardRef(
}
) as Polymorphic.ForwardRefComponent<
"div",
ComboboxPopoverProps & Partial<PopoverProps>
ComboboxPopoverProps &
Partial<Omit<PopoverProps, "unstable_skipInitialRender">>
>;

if (__DEV__) {
Expand Down
1 change: 1 addition & 0 deletions packages/dropdown/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@ const DropdownPopover = React.forwardRef(
as={Comp}
targetRef={targetRef as any}
position={position}
unstable_skipInitialPortalRender
/>
) : (
<Comp {...props} {...sharedProps} />
Expand Down
1 change: 1 addition & 0 deletions packages/listbox/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ const ListboxPopoverImpl = React.forwardRef(function ListboxPopover(
targetRef={buttonRef as any}
position={position}
unstable_observableRefs={unstable_observableRefs}
unstable_skipInitialPortalRender
/>
) : (
<Comp {...commonProps} />
Expand Down
3 changes: 2 additions & 1 deletion packages/menu-button/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ const MenuPopover = React.forwardRef(
as={Comp}
targetRef={targetRef as any}
position={position}
unstable_skipInitialPortalRender
/>
) : (
<Comp {...props} {...sharedProps} />
Expand Down Expand Up @@ -475,7 +476,7 @@ if (__DEV__) {
function useMenuButtonContext(): MenuContextValue {
let {
state: { isExpanded },
} = useDropdownContext();
} = useDropdownContext("useMenuButtonContext");
return React.useMemo(() => ({ isExpanded }), [isExpanded]);
}

Expand Down
8 changes: 6 additions & 2 deletions packages/popover/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ import type * as Polymorphic from "@reach/utils/polymorphic";
/**
* Popover
*/
const Popover = React.forwardRef(function Popover(props, ref) {
const Popover = React.forwardRef(function Popover(
{ unstable_skipInitialPortalRender, ...props },
ref
) {
return (
<Portal>
<Portal unstable_skipInitialRender={unstable_skipInitialPortalRender}>
<PopoverImpl ref={ref} {...props} />
</Portal>
);
Expand All @@ -43,6 +46,7 @@ interface PopoverProps {
* anywhere in public yet!
*/
unstable_observableRefs?: React.RefObject<PossibleNode>[];
unstable_skipInitialPortalRender?: boolean;
}

if (__DEV__) {
Expand Down

0 comments on commit 0c21334

Please sign in to comment.