Commit 8f64b22
committed
Fix crash when removing a link mark with no active mark present
The link toolbar's onRemove handler called editor.removeMark()/
removeMarkAtRange() with the result of an unguarded Array.find(),
which is undefined whenever the selection has no active link mark.
Slate's Mark.create() silently defaults an undefined argument to {}
and passes it to Mark.fromJSON(), which throws "Mark.fromJS()
requires a type string." This is reached whenever a user opens the
Link popover and confirms an empty URL field without ever having
applied a link (Enter or the Add button triggers onConfirm, which
delegates to onRemove when the field is blank).
Guard onRemove the same way the neighboring removeMarksOfTypeInRange
helper already does: no-op when there's no active mark to remove.1 parent 52fd9fb commit 8f64b22
1 file changed
Lines changed: 7 additions & 0 deletions
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
204 | 211 | | |
205 | 212 | | |
206 | 213 | | |
| |||
0 commit comments