paljs/ui

Possible breaking change with usePopoverPosition event propagation after upgrade to React 17

Opened this issue · 1 comments

The window.addEventListener and window.removeEventListener calls in the following area may need the { capture: true } option added due to a change in how React 17 now attaches event listeners to the root app element. I was using this hook in a custom component that expected click events on other popover targets to bubble up (not calling event.stopPropagation) and trigger closing of the currently displayed popover. This stopped working properly after upgrading to React 17 seemingly due to the bubbling now only going up to the root app element.

window.addEventListener('resize', positionHandle);
window.addEventListener('orientationchange', positionHandle);
layout.addEventListener('scroll', positionHandle);
window.addEventListener('click', onClickHandle);
if (props.eventListener) {
document.querySelector(props.eventListener)?.addEventListener('scroll', positionHandle);
}

See https://reactjs.org/blog/2020/08/10/react-v17-rc.html#fixing-potential-issues

Thanks for reporting. I will work on this issue and push new release asap.