Commit a1a6a97
Fix popover not calling onClose on unmount (#71252)
* Run onClose when unmounting component
There was a cancelBlurCheck running on unmount, which prevented the onClose for the popover from running when the popover was unmounted.
* Add test coverage for hook
* Improve useFocusOutside test with Promise.withResolvers()
Replace fragile setTimeout approach with Promise.withResolvers() to make
the test more reliable and faster. The test now waits for the actual
callback to be called rather than an arbitrary timeout.
Addresses feedback from PR #71252 review.
* Fix Node.js compatibility: replace Promise.withResolvers() with manual deferred pattern
Promise.withResolvers() is only available in Node.js 22+, but the project
requires Node.js >=20.10.0. Use the traditional manual deferred promise
pattern for better compatibility.
This maintains the same improved test reliability while ensuring
compatibility with the project's Node.js version requirements.
---------
Co-authored-by: Dave Smith <getdavemail@gmail.com>
Co-authored-by: jeryj <jeryj@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: stokesman <presstoke@git.wordpress.org>1 parent d95302f commit a1a6a97
2 files changed
+20
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | 90 | | |
96 | 91 | | |
97 | 92 | | |
| |||
Lines changed: 20 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
120 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
121 | 127 | | |
122 | 128 | | |
123 | 129 | | |
| |||
130 | 136 | | |
131 | 137 | | |
132 | 138 | | |
133 | | - | |
134 | | - | |
135 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
136 | 147 | | |
137 | 148 | | |
138 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
139 | 153 | | |
140 | 154 | | |
0 commit comments