Use an explicit trigger API
The component owns a native button, so aria-describedby and focus events belong to the element receiving focus. A generic wrapper around arbitrary children does not ensure that relationship. Supporting arbitrary triggers later needs a deliberate ref and event-composition API.
Track reasons to remain open
Trigger hover, tooltip hover, and trigger focus are separate engagement reasons. Leaving the button with the mouse must not hide help while the button is still focused. Close only after all reasons end, using a 120ms delay to bridge the pointer gap; entering either surface cancels that delay.
Make Escape persistent
Listen for Escape only while open. Dismiss the tooltip, retain button focus, and remember that the current engagement was dismissed. Reset that guard only once hover and focus have ended. Otherwise a fresh mouse-enter event can reopen help that the user just closed.
Portal and position are separate jobs
Portalling to document.body escapes ordinary clipping by the demo ancestor. It does not solve every stacking context or place content above a modal top layer. Fixed positioning uses getBoundingClientRect coordinates directly. Measure both rectangles, try the preferred side, use its opposite if it does not fit, and clamp the final coordinates. Constrain text width so it can wrap.
Keep geometry current and clean up
A layout effect measures before painting. Scroll events from nested containers are observed with capture; resize also recalculates placement. Remove both listeners when closed and clear delayed-close work on unmount. Each instance uses useId so descriptions do not collide.
Check combined interactions
Focus the button, move the mouse away, and confirm help remains. Move from trigger to popup before the delay expires. Press Escape: focus stays and the popup disappears. Fully leave and blur, then return to reopen. Test all four placements near viewport edges and scroll an ancestor while open.