Commit a302e05
fix: various mentions bugs and inconsistencies between platforms (#637)
# Summary
There were various bugs and inconsistencies with mentions
functionalities across every platform.
Mainly it wasn't handled properly when you switched **directly** between
different mentions, which caused improper event emission and the lists
stayed visible - documented in the videos section
iOS:
- events not emitted when switching directly between mentions
- duplicated `onChange` events when just moving a cursor across a
mention
- `_recentInputString` was not updated if no `onChangeText` prop was
given
Android:
- events not emitted when switching directly between mentions
- on selection changes, the mentions were not reanalyzed and no events
were emitted
- when `setMention` a duplicated space was inserted if there already was
one
- `setMention` wasn't replacing the surrounding text
- after `setMention` the selection wasn't moved to the trailing space
Web:
- refactor on the event subscription hook for consistency
- mention query was evaluated to a cursor position, not the whole
written mention, which produced leftover text when inserting a mention
- unnecessarily considered a finalized mention into the query
- events not emitted when switching directly between mentions
- when `setMention` a duplicated space was inserted if there already was
one
Example apps:
- updated example apps with more idiomatic code. Earlier `onChange`
mention event would handle popup list opening - something what `onStart`
is for
## Test Plan
Follow the text written in the attached videos, play around with
selection changes, all events should emit correctly and the lists should
function as expected.
## Screenshots / Videos
(all platforms) events not emitting when switching between mentions
https://github.com/user-attachments/assets/cc408357-ae3f-41ed-87ce-c6192149539b
(web) incorrect query evaluation and inserting, doubled space
https://github.com/user-attachments/assets/4981556a-c8c6-4139-855e-957fa9dc4754
(android) `setMention` not replacing surrounding text:
https://github.com/user-attachments/assets/37fb805c-aaa1-4947-a8dd-4d1427ab1629
## Compatibility
| OS | Implemented |
| ------- | :---------: |
| iOS | ✅ |
| Android | ✅ |
| Web | ✅ |
## Checklist
- [x] E2E tests are passing
- [x] Required E2E tests have been added (if applicable)
---------
Co-authored-by: Kacper Żółkiewski <74975508+kacperzolkiewski@users.noreply.github.com>
Co-authored-by: Mikołaj Szydłowski <9szydlowski9@gmail.com>1 parent 3a5d492 commit a302e05
26 files changed
Lines changed: 430 additions & 180 deletions
File tree
- .maestro/enrichedInput
- flows
- screenshots
- android
- ios
- subflows
- .playwright/tests
- android/src/main/java/com/swmansion/enriched/textinput
- events
- styles
- utils
- apps
- example-web/src
- testScreens
- example
- src
- hooks
- screens
- ios
- styles
- src/web
- pmPlugins/MentionPlugin
Lines changed: 45 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
44 | 48 | | |
45 | 49 | | |
46 | 50 | | |
| |||
263 | 267 | | |
264 | 268 | | |
265 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
Lines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
30 | 40 | | |
31 | | - | |
32 | 41 | | |
33 | 42 | | |
34 | 43 | | |
35 | 44 | | |
36 | 45 | | |
37 | 46 | | |
38 | 47 | | |
39 | | - | |
| 48 | + | |
40 | 49 | | |
| 50 | + | |
41 | 51 | | |
42 | 52 | | |
43 | 53 | | |
| |||
0 commit comments