fix(Popper): add null & connected checks for document#12284
fix(Popper): add null & connected checks for document#12284kmcfaul wants to merge 1 commit intopatternfly:mainfrom
Conversation
WalkthroughUpdated Popper utility system to add defensive checks: enhanced Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Preview: https://pf-react-pr-12284.surge.sh A11y report: https://pf-react-pr-12284-a11y.surge.sh |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/react-core/src/helpers/Popper/thirdparty/react-popper/usePopper.ts (1)
128-130: Please add a regression test for detached→connected transitions.Lines 128-130 correctly gate initialization on
isConnected; adding a test for reconnection flow would lock in this behavior and prevent regressions.If you want, I can draft the exact test cases for
referenceElementandpopperElementconnectivity transitions.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/react-core/src/helpers/Popper/thirdparty/react-popper/usePopper.ts` around lines 128 - 130, Add a regression test for the detached→connected transition that verifies usePopper initializes once elements reattach: mount a component that uses usePopper with a referenceElement and popperElement initially not connected (e.g., created but not appended to document), assert that initialization does not run while isReferenceConnected(referenceElement) or popperElement.isConnected are false, then append both elements to document (or reattach the reference) and assert the hook creates/initializes the popper (spy or assert popperInstance/instance creation or that the popper update method was called). Target the usePopper hook and the gating checks isReferenceConnected, referenceElement, and popperElement to ensure the reconnection flow is covered and prevents regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/react-core/src/helpers/Popper/thirdparty/react-popper/usePopper.ts`:
- Around line 128-130: Add a regression test for the detached→connected
transition that verifies usePopper initializes once elements reattach: mount a
component that uses usePopper with a referenceElement and popperElement
initially not connected (e.g., created but not appended to document), assert
that initialization does not run while isReferenceConnected(referenceElement) or
popperElement.isConnected are false, then append both elements to document (or
reattach the reference) and assert the hook creates/initializes the popper (spy
or assert popperInstance/instance creation or that the popper update method was
called). Target the usePopper hook and the gating checks isReferenceConnected,
referenceElement, and popperElement to ensure the reconnection flow is covered
and prevents regressions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e3de51a5-434e-4d7a-8da2-2302dc4e4f66
📒 Files selected for processing (2)
packages/react-core/src/helpers/Popper/thirdparty/popper-core/dom-utils/getDocumentElement.tspackages/react-core/src/helpers/Popper/thirdparty/react-popper/usePopper.ts
What: Closes #12255
Adds a fallback to
window.documentforgetDocumentElement.tsand addsisConnectedchecks foruseIsomorphicLayoutEffectbeforecreatePopperis called.