Commit 5171b33
committed
fix: prevent stale closure in handlePaste for rapid paste events
Use refs to track latest value and cursorPosition instead of relying
on closure-captured values. This fixes an issue where only the last
character would be pasted when multiple paste events fire rapidly
before React has a chance to re-render.
The refs are also updated synchronously in the handler so subsequent
events see the updated state.1 parent b2e7516 commit 5171b33
1 file changed
+24
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
139 | 149 | | |
140 | 150 | | |
141 | 151 | | |
| |||
170 | 180 | | |
171 | 181 | | |
172 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
173 | 188 | | |
174 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
175 | 196 | | |
176 | 197 | | |
177 | | - | |
| 198 | + | |
178 | 199 | | |
179 | 200 | | |
180 | 201 | | |
181 | | - | |
| 202 | + | |
182 | 203 | | |
183 | 204 | | |
184 | 205 | | |
| |||
0 commit comments