-
Notifications
You must be signed in to change notification settings - Fork 1.2k
destructing of placement from useOverlayPosition logged to the console undefined #4315
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
Comments
Can you provide a codesandbox demonstrating the issue? Otherwise it's hard to tell what's going on since it's always appearing defined for the sample of stories I looked at in our storybook. |
There's two console.logs one for each file , as you can see the console.log of the trigger file is yelling undefined |
It will be very helpful if there was a link to codesendbox with each example demo that in the site so we can learn faster. |
Here is a working example https://codesandbox.io/p/sandbox/festive-mahavira-obc10p?file=%2Fapp%2Fpopover%2FPopover.tsx With usePopover, you shouldn't need to worry about useOverlyPosition anymore yourself. Sorry that's a bit confusing, probably due to a dead page in our docs that hasn't been pruned yet. One thing I noticed is that you had React StrictMode turned on. We don't support that yet, but we are working on supporting it. We're tracking it here #779 |
Closing since this has a working example, feel free to reopen if you have further issues/concerns. |
It's not really a working example, it doesn't use the same hook. You see it at first load: https://codesandbox.io/p/sandbox/dazzling-antonelli-9xv2kx |
That probably has more to do with Typescript Strict communicating what to expect. It may be when we update that, we'll decide to return an empty object. For now, you can either turn it into an empty object yourself or use
|
Sorry, I am not sure I understand, or I was not clear enough. |
I think you're asking, why is this https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/overlays/src/useOverlayPosition.ts#L70, even though it's defined as required in the types, actually undefined?
Does that help? or am I still missing your question? |
All good now, thanks for the clarification. Yes, I realized what happened for 2. and also saw that the Tooltip component has a Would be nice, indeed, to improve |
🐛 Bug Report
let { overlayProps: positionProps, placement } = useOverlayPosition({
targetRef: triggerRef,
overlayRef,
placement: 'left',
offset: props.offset || 8,
isOpen: state.isOpen,
shouldUpdatePosition:true
});
console.log(placement); //yield undefined
🤔 Expected Behavior
I'm new to this library but I'm pretty sure that it should log left
(it reside inside a PopupTrigger, and PopupTrigger has a child of Popover and inside this there's usePopover which destruct placement properly with a value, so Why it's not working on the PopupTrigger with useOverlayPosition)
😯 Current Behavior
But it's undefined
💁 Possible Solution
🔦 Context
💻 Code Sample
🌍 Your Environment
🧢 Your Company/Team
🕷 Tracking Issue (optional)
The text was updated successfully, but these errors were encountered: