Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #5733: MenuPlacer useLayoutEffect depend on isLoading #5736

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/react-select/src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1961,7 +1961,11 @@ export default class Select<
};

const menuElement = (
<MenuPlacer {...commonProps} {...menuPlacementProps}>
<MenuPlacer
{...commonProps}
{...menuPlacementProps}
isLoading={isLoading}
>
{({ ref, placerProps: { placement, maxHeight } }) => (
<Menu
{...commonProps}
Expand Down
3 changes: 3 additions & 0 deletions packages/react-select/src/components/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ export interface MenuPlacerProps<
MenuPlacementProps {
/** The children to be rendered. */
children: (childrenProps: ChildrenProps) => ReactElement;
isLoading: boolean;
}

function alignToControl(placement: CoercedMenuPlacement) {
Expand Down Expand Up @@ -317,6 +318,7 @@ export const MenuPlacer = <
) => {
const {
children,
isLoading,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@labkey-nicka I'm not a maintainer but while fixing the same issue I found that you can get the isLoading property from props.selectProps.isLoading. Therefore, we might not need an extra isLoading prop here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks! Indeed isLoading is available on props.selectProps. Refactored and updated.

minMenuHeight,
maxMenuHeight,
menuPlacement,
Expand Down Expand Up @@ -353,6 +355,7 @@ export const MenuPlacer = <
setPlacement(state.placement);
setPortalPlacement?.(state.placement);
}, [
isLoading,
maxMenuHeight,
menuPlacement,
menuPosition,
Expand Down