Skip to content

Fix resize loop issue #8164

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions packages/@react-aria/overlays/src/useOverlayPosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export function useOverlayPosition(props: AriaPositionProps): PositionAria {
let overlay = (overlayRef.current as HTMLElement);
if (!maxHeight && overlayRef.current) {
overlay.style.top = '0px';
overlay.style.left = '0px';
overlay.style.bottom = '';
overlay.style.maxHeight = (window.visualViewport?.height ?? window.innerHeight) + 'px';
}
Expand Down
27 changes: 26 additions & 1 deletion packages/react-aria-components/stories/Popover.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {Button, Dialog, DialogTrigger, Heading, OverlayArrow, Popover} from 'react-aria-components';
import {Button, Dialog, DialogTrigger, Heading, MenuTrigger, OverlayArrow, Popover} from 'react-aria-components';
import React, {useEffect, useRef, useState} from 'react';

export default {
Expand Down Expand Up @@ -433,3 +433,28 @@ export const PopoverTriggerWidthExample = () => (
</Popover>
</DialogTrigger>
);

const PopoverRightExampleContent = () => {
const [s, ss] = useState(false);
useEffect(() => {
setTimeout(() => {
ss(true);
}, 1500);
});
return s ? (
<div>
Longer content goes here. Hello, World! This is a popover.
</div>
) : (
<div>Short content goes here.</div>
);
};

export const PopoverRightExample = () => (
<MenuTrigger>
<Button style={{marginLeft: 'auto'}}>Open popover</Button>
<Popover placement="bottom end">
<PopoverRightExampleContent />
</Popover>
</MenuTrigger>
);
Copy link
Author

Choose a reason for hiding this comment

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

This story is more of a test, to reproduce the issue before the fix and to verify it works correctly after the fix. Is there a better place to do that? If not, what should I name it? I wanted to write a unit test, but I'm not sure how to write it.

Copy link
Member

Choose a reason for hiding this comment

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

it's fine to have a storybook example for something like this, it's really hard to reproduce in a unit test

one option could be to use storybook's "play" feature and see if you can use that to automate what should happen

Comment on lines +453 to +460
Copy link
Member

Choose a reason for hiding this comment

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

There are some examples around the code base of how to add a description to the story so we know how to test it in the future. You may need to adjust the code sample I wrote below.

Suggested change
export const PopoverRightExample = () => (
<MenuTrigger>
<Button style={{marginLeft: 'auto'}}>Open popover</Button>
<Popover placement="bottom end">
<PopoverRightExampleContent />
</Popover>
</MenuTrigger>
);
export const PopoverRightExample = {
render: () => (
<MenuTrigger>
<Button style={{marginLeft: 'auto'}}>Open popover</Button>
<Popover placement="bottom end">
<PopoverRightExampleContent />
</Popover>
</MenuTrigger>
),
parameters: {description: 'how to test this story, what does it do?'},
name: 'more descriptive name?'
};