fix: error overlay not closing when backdrop clicked (#83981)
The ref object wasn't passed to the hook; instead, ref.current (the
value) was passed. This caused `useOnClickOutside` to be noop on initial
render when ref.current was null, and only worked later because the
component re-rendered with a different value. The fix ensures the hook
always has access to the current DOM element whenever the effect runs.
### Before
https://github.com/user-attachments/assets/baa7ea6c-9506-4f14-8950-b4e7e7abbe61
### After
https://github.com/user-attachments/assets/18c3c569-ca30-41c3-ae92-f2d3e8fcee4c