Commit 0a4b0b3
authored
fix(superdoc): restore find input focus after match navigation (SD-3045) (#3240)
* fix(superdoc): restore find input focus after match navigation (SD-3045)
The Search extension's goToSearchResult calls editor.view.focus() so the
new selection is visible. When the user pressed Enter in the built-in find
input, the synchronous focus steal blurred the input — subsequent Enter
keystrokes were swallowed by the ProseMirror editor, splitting paragraphs
at the match position, invalidating the search session, and resetting the
active match index. The user had to click back into the input between
every navigation.
Re-focus the find input synchronously after goNext / goPrev so repeated
Enter / Shift+Enter keeps advancing through matches and the editor never
receives the keystroke.
* fix(superdoc): scroll cross-page search matches into view reliably (SD-3045)
Pressing Enter or clicking next/prev on a search match that lives on a
different page often left the match just below the visible area, slightly
above the viewport, or didn't scroll at all. Three races were colluding:
1. The Vue surface lives in the document's normal flow, so any focus or
.select() on its input or buttons triggers the browser's
scroll-element-into-view behaviour and snaps the document back to the
find bar — undoing the goNext scroll. Drop .select() (cmd+A still
works), focus with preventScroll: true, and pin every scrollable
ancestor's scrollTop across the focus call. Route the button clicks
through the same goNext/goPrev → focusFindInput path so all three
navigation entry points (Enter, Shift+Enter, button click) have the
same focus-restore guarantee.
2. PresentationEditor.scrollToPosition runs after dispatch(setSelection),
but the selectionUpdate emitted by that dispatch sets
#shouldScrollSelectionIntoView = true. The next #updateSelection then
calls #scrollActiveEndIntoView and snaps the caret to its
minimum-visibility position (often 20px from the viewport edge),
visibly displacing the match. Consume the flag inside
scrollToPosition.
3. A later selectionUpdate (focus blur as the user moves focus back to
the find input, or async PM events) re-sets the flag to true after we
consumed it, and the RAF-deferred #updateSelection scrolls the caret
again. Re-assert the scrollIntoView on the next animation frame so any
such late displacement is corrected; the no-op case is cheap.
Tests cover all three: Enter / Shift+Enter / button-click focus restore
use { preventScroll: true } on the find input. Manual repro on Luccas's
finding1.docx fixture: 4 'titlePg' matches across 3 pages — every click
now lands with the match in the centre of the viewport.
* fix(superdoc): make search highlight win over inline background-color (SD-3045)
Search matches were invisible on runs whose source rPr carried a highlight
mark (e.g. `<w:highlight w:val="white"/>`). The DomPainter writes
`style.backgroundColor = run.highlight` inline on the same span the
DecorationBridge later tags with `.ProseMirror-search-match`, and inline
styles win over class selectors — so the find colour was painted over.
Add `!important` to both search-match background rules (the `.superdoc`
scope used in presentation mode and the `.sd-editor-scoped` scope used by
the hidden editor) so the transient find colour overrides any source-doc
highlight while a search session is live. The class is only present during
a search; clearing it restores the original highlight.
Repro: load `basic/advanced-text.docx` from the corpus, search for "Oscar".
5 of 8 matches sit in runs imported as `highlight: { color: '#FFFFFF' }`
and had no visible find highlight pre-fix. All 8 are now correctly coloured.
Regression test asserts !important is present in both CSS files plus a
JSDOM specificity sanity check showing the rule wins over an inline white.1 parent d4d2eb1 commit 0a4b0b3
6 files changed
Lines changed: 477 additions & 11 deletions
File tree
- packages
- super-editor/src/editors/v1
- assets/styles/elements
- core/presentation-editor
- superdoc/src
- assets/styles/elements
- components/surfaces
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
435 | 439 | | |
436 | | - | |
| 440 | + | |
437 | 441 | | |
438 | 442 | | |
439 | | - | |
| 443 | + | |
440 | 444 | | |
441 | 445 | | |
442 | 446 | | |
| |||
Lines changed: 31 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3534 | 3534 | | |
3535 | 3535 | | |
3536 | 3536 | | |
3537 | | - | |
| 3537 | + | |
| 3538 | + | |
| 3539 | + | |
| 3540 | + | |
| 3541 | + | |
| 3542 | + | |
| 3543 | + | |
| 3544 | + | |
| 3545 | + | |
| 3546 | + | |
| 3547 | + | |
| 3548 | + | |
| 3549 | + | |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
| 3556 | + | |
| 3557 | + | |
| 3558 | + | |
| 3559 | + | |
| 3560 | + | |
| 3561 | + | |
| 3562 | + | |
| 3563 | + | |
| 3564 | + | |
| 3565 | + | |
| 3566 | + | |
| 3567 | + | |
3538 | 3568 | | |
3539 | 3569 | | |
3540 | 3570 | | |
| |||
Lines changed: 102 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 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
43 | 52 | | |
44 | | - | |
| 53 | + | |
45 | 54 | | |
46 | 55 | | |
47 | 56 | | |
48 | | - | |
| 57 | + | |
49 | 58 | | |
50 | 59 | | |
51 | 60 | | |
| |||
0 commit comments