Comments (6)
I couldn't reproduce this with React 17 or 18 with a basic snapshot test using Vitest (both conditional and unconditional FloatingPortal
rendering based on an open
state), using latest @testing-library/react
and jsdom
. Maybe it's a React 16 problem in a testing env, or something else, but it doesn't seem to be an actual bug. Feel free to provide a reproduction if you have the ability, but for now, I'm closing due to lack of ability to reproduce the issue.
from floating-ui.
Is this only in snapshot tests? In the browser it's defined with both conditional and unconditional rendering.
from floating-ui.
Yes, you're right, it happens only in jest snapshots, any idea why it could be?
from floating-ui.
Hi, I finally managed to set up a reproduction: https://stackblitz.com/edit/vitejs-vite-erxqfe?file=src%2F__snapshots__%2FPopover.spec.js.snap
you can see id="undefined"
at line 19
from floating-ui.
Have you tried:
- Upgrading to React 18, which uses the native
useId()
hook and has better perf (I'm going to drop React 17 support when React 19 comes out in a few months anyway) - Adding
act(async () => {})
after therender()
call in the test async (it breaks in Stackblitz, not sure why) - Avoiding snapshot tests which can easily break when implementation details of this library change (such as here) even though it's not actually broken for real users
from floating-ui.
- I'm maintaining an npm module so I'm not free to upgrade to React 18 right away, until my consumers are ready.
- using act doesn't seem to change this behaviour.
- I know snapshots tests are very limited, but they actually helped in finding bugs after library upgrades. They can be replaced for sure with better tests, but until we don't have the resources to do that, that's the best we have.
I understand my specific issue shouldn't be a priority for you and I'm glad you always take the time to answer in zero time. Thank you!
from floating-ui.
Related Issues (20)
- Option is not scrolled into view when opening by clicking on reference HOT 1
- autofocus input in floating element will make window scroll to top HOT 3
- Ignore `website/` dir for `build` command HOT 2
- [flip] Name overflowing directions
- Dynamic focus manager elements create ARIA violations. HOT 2
- useFocus: floating element does not disappear if it has focusable children and you blur by tabbing HOT 2
- Position issue when scroller is inside another scroller HOT 8
- Combine flip and shift middleware doesn't keep original placement HOT 9
- npm ERR! notarget No matching version found for @floating-ui/dom@^1.6.0. HOT 3
- `useHover` without safePolygon is missing `mouseEnter` / `mouseLeave` HOT 2
- Virtual element sometimes leaves the wrapper element specified HOT 2
- Placement of popper is not working correctly HOT 3
- [DOM] `popover` attribute collision detection fails with `absolute` strategy HOT 1
- Need help to make ui like this HOT 2
- Shift middleware with a boundary doesn't respect bondary bottom edge HOT 10
- exceeding the boundary HOT 1
- Detect `event.target.matches(':hover')` in `useFocus onBlur` handler HOT 2
- when return value of the `getElementRects` is a DOMRect, only the `x` , `y` fields exist in rect in `convertOffsetParent34` method
- computePosition is not returning position properly for SVG Element inside <mask> for FireFox HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from floating-ui.