Skip to content

Find text in the open pad #250

Closed
Closed

Description

@HMarzban

Parent

#249 Deepen the installed PWA. Sibling of #247, #248, and #251. Not blocked by them.

What to build

Add caret find on the open pad. The user types a query, sees hits, and steps the caret to the next or previous hit.

Filter stays Filter. It hides Sections. It is not find. Rename the Filter field so it no longer says “Find in document”.

Acceptance criteria

  • Desktop and phone: a Find control opens a find bar on the pad. It does not open Filter.
  • That control sits next to Filter (same desktop toolbar, same phone host). Do not add a new 32 by 32 docked control.
  • Desktop: Mod-f opens that bar and does not open the browser find dialog.
  • Escape closes the bar and restores the fold snapshot taken when the bar opened.
  • Enter moves to the next hit. Shift-Enter moves to the previous hit. The caret lands in the current hit.
  • The query is a case-insensitive literal. Empty query clears hits. No regex. No replace.
  • Search walks the pad document, including Title. It does not search Pad title, chat, or History.
  • A viewer under Read-only or Editing lock can still find. History view has no find bar.
  • The current hit is visible. Unfold its Section. Keep every other fold from the open snapshot.
  • Hit paint uses a new decoration class. It does not write the Highlight mark. It does not reuse the Filter wash.
  • A polite live region outside the editor speaks the current index and the hit count, for example 3 of 12.
  • More than 200 hits: paint at most 200, show 200+, and step only those 200.
  • Find does not change the URL. It does not write filter path segments.
  • Filter field aria-label and placeholder no longer say “Find in document”. The panel title stays Filter.
  • Light and dark, desktop and phone: the bar is a compact pad control, not a BottomSheet.

Agent Brief

Category: enhancement
Summary: Real find on the pad, plus an honest Filter label.

Current behavior:
The Filter panel title is Filter. Its field still says “Find in document”. Apply hides unmatched Sections. It does not step hits or move the caret.

Folded Section bodies use display: none. Browser find cannot see them. The pad does not bind Mod-f.

matchSections skips Title and the nodes under Title. It is a Section index for Filter. It is not the hit engine.

A viewer can already run Filter. History unmounts the pad editor.

Desired behavior:
Open a find bar from a toolbar control next to Filter. On desktop, Mod-f opens the same bar and steals browser find. That steal is required, because folded text is hidden from the page.

Walk the live pad document. Include Title. Ignore Pad title, the chat composer, and History.

Treat the query as a trimmed, case-insensitive substring. Do not add whole-word, regex, or replace.

When the bar opens, snapshot the current folds. For the current hit, unfold that Section only. Leave the rest of the snapshot in place. Do not replace the whole fold set with one id. Closing the bar restores the snapshot. Filter can stay on.

Paint hits with a new inline decoration class. Do not write the stored Highlight mark. Do not reuse the Filter highlight class. Do not put a live region inside the editor.

Cap paint and stepping at 200 hits. If there are more, show 200+.

A Read-only viewer can find. An Editing lock still allows find. Do not run find when History has unmounted the pad.

#175 is theme flip and a two-key help dialog. Do not add find to that help table.

Key interfaces:

  • Caret find — bar, next, previous, caret on the current hit
  • Filter — Section hide only; field no longer claims find
  • Title — first heading; included in search
  • Pad title — header name; not searched
  • Section — heading plus following nodes; unfold the one that holds the current hit
  • Editing lock — blocks edits; does not block find
  • Highlight — stored mark; do not use it to paint hits

Out of scope

Activity

  1. added
    enhancement
    Editor
    on Sep 9, 2026
  2. HMarzban commented on Sep 9, 2026

    @HMarzban
    CollaboratorAuthor

    Sibling slash menu is #251. Both sit under #249.

  3. HMarzban commented on Sep 9, 2026

    @HMarzban
    CollaboratorAuthor

    Cohesion

    Find is pad text. It is not Settings → Documents “Search documents”. It is not Filter.

    iOS and macOS Safari

    • macOS Safari: Mod-f must open the find bar and stop Safari’s own find. Folded text is display: none, so Safari find misses it.
    • iPhone and iPad: the Find toolbar control opens the same compact bar. Do not use a BottomSheet. A sheet drops the iOS keyboard.
    • Keep the bar above the visual viewport. Next and previous stay tappable while the keyboard is open.
    • A hardware keyboard on iPad may use Enter and Shift-Enter. Software keyboard still needs on-bar next and previous.
  4. HMarzban commented on Sep 9, 2026

    @HMarzban
    CollaboratorAuthor

    Safari follow-up from iOS find slash jump:

    • Mac Safari: preventDefault on Mod-f can steal Find on Page. Prove that steal.
    • iPhone and many iPad Cmd-f events never reach JS. Keep the Find control. A failed steal is not a bug.
    • Do not reuse matchSections as the hit engine. It skips Title.
  5. HMarzban commented on Sep 9, 2026

    @HMarzban
    CollaboratorAuthor

    Spec review: Find sits next to Filter. No new docked 32 by 32 control.

  6. HMarzban commented on Sep 10, 2026

    @HMarzban
    CollaboratorAuthor

    UX cohesion (epic #249):

    Find is caret step through pad text. It is not Filter (hide Sections) and not Command jump (go to a place).

    The bar is a compact L0 pad control next to Filter (ToolbarButton + daisyUI input). Not a BottomSheet, not FilterPanel, not Spotlight.

    This card owns open, close, Escape, and the polite live region. #248 does not cover the find bar. Do not add Find to the #175 help table.

  7. added this to the v2.3.0 milestone on Oct 24, 2026
  8. HMarzban commented on Nov 3, 2026

    @HMarzban
    CollaboratorAuthor

    Status, 2026-11-03. Built in f167903, which ships in v2.1.0. #393 then moved the bar to float in the editor column and made Mod-F the only desktop entry (f083ac6, 23b8939). The #308 fix (99a2444) is pushed and deployed on 2026-11-03. It hides the phone edit toolbar on a read-only pad. Left:

  9. HMarzban commented on Nov 4, 2026

    @HMarzban
    CollaboratorAuthor

    Status, 2026-11-04. The acceptance list predates #393. Read it with these changes: there is no desktop toolbar Find control, Mod-F is the only desktop entry, and the cap is 9,999 steps with 200 painted.

    Left:

    • [maintainer] macOS Safari: Cmd-F on a pad opens the pad Find bar, not Safari find.
    • iPhone, read-only pad: with Find open, no edit toolbar shows. The iPhone simulator can run this row.
  10. HMarzban commented on Nov 4, 2026

    @HMarzban
    CollaboratorAuthor

    Withdrawn, 2026-11-04. The Home jump below came from stale simulator clicks, not from the app. See the correction: #250 (comment)

    Simulator check, 2026-11-04. The iPhone read-only row is blocked: the phone Find bar never opened, because a new defect sends the user to Home.

    Setup: iPhone 17 Pro simulator, iOS 26.5, Safari, signed out. Local main at 91aeeaa8a, and production docs.plus/demo.

    Defect: on a phone, the drawer's Find and Filter buttons go to Home (/).

    1. Open a pad. Tap the menu icon to open the outline drawer. The browser Back button turns active, so the drawer adds a history entry.
    2. Tap Find (magnifier) in the drawer footer, once.
    3. The app loads Home. No Find bar shows.
    • It reproduces on production (docs.plus/demo) with one tap. So it is not from the unpushed local commits.
    • It reproduces on a read-only pad (qa-device-ro-1026) and on an editable pad (qa-device-target-1026).
    • Filter in the same footer does the same. Both use closeTocThen in TocModal.tsx, which calls closeModal() and then the action. Closing the drawer with X keeps the pad. A pad left alone for 45 s stays put.
    • The cause is not found yet. A likely place is how the drawer's close step goes back in history, followed by the action. That is read from the symptom, not measured.

    Also seen: the Edit button shows on the read-only pad while the keyboard is down, and a tap does nothing (enableEditor returns early when isDocumentEditingLocked() is true).

    Left:

    • Fix the drawer Find and Filter jump to Home on phones.
    • Then re-run this row: Find field focused, keyboard up, step next and previous, and no edit toolbar or Edit button shows. Under the 2026-11-03 ruling the simulator can close it.
    • [maintainer] macOS Safari Cmd-F.
  11. HMarzban commented on Nov 4, 2026

    @HMarzban
    CollaboratorAuthor

    Correction, 2026-11-04: the drawer Find and Filter defect in my comment above is not real. It came from the simulator's input, not from the app.

    How I found it: I added a temporary on-screen log of history calls, touches and clicks, then repeated the same taps.

    • The touch events arrived at the new tap point, for example (161, 681). But mousedown, mouseup and click fired at the previous tap point, (24, 24).
    • (24, 24) is the menu icon. When the drawer is open, the docs.plus logo sits at that point, and it is a Go to home link. So the stale click opened Home through a Next Router.push('/'). No history.back() was involved.
    • Real Safari fires the click at the touch point. No app code creates clicks.

    Checks that pass:

    • iPhone 17 Pro simulator, once taps reached the right point: drawer → Find opens the Find bar and the keyboard, locally and on production docs.plus/demo.
    • In-app browser with phone emulation (html.m_mobile): drawer → Find opens the Find bar. Drawer → Filter opens the Filter sheet, and the sheet takes over the drawer's history entry. Closing the sheet leaves the pad entry, and the marker is gone. The URL stays on the pad throughout.

    No code change was made.

    Still left on this issue:

    • The read-only row on the simulator. While the click lag lasts, simulator taps are not reliable evidence. Re-run it after a simulator restart, or on a real iPhone.
    • [maintainer] macOS Safari Cmd-F.
    • The Edit button on a read-only pad (it shows, and a tap does nothing) is still a real observation. It is a UX question, not a blocker for this issue.
  12. HMarzban commented on Nov 9, 2026

    @HMarzban
    CollaboratorAuthor

    Device checks, 2026-11-09. Local stack. These cover the two legs left in the 2026-11-04 status.

    iPhone, read-only pad. QA iPhone 17 Pro simulator, iOS 26.5, Safari 26.5. Pad qa-device-ro-1026, viewer Swarm Actor 1 (not the owner). Touch and click points matched on every tap, so the 2026-11-04 click lag is gone.

    • Drawer → Find opens the Find bar. The URL stays on the pad.
    • The Find field has focus with the software keyboard up (visualViewport.height 404 against 714).
    • Query te, typed on the on-screen keys. Next and Previous step 1 of 4 → 2 → 3 → 2 → 1 → 4 of 4. Focus and the keyboard stay up.
    • No edit toolbar shows. The Edit button is absent. The editor stays contenteditable="false".

    macOS Safari 27.0.1, Cmd-F. Driven by safaridriver on a fresh pad.

    • A trusted Meta+f with the pad focused had defaultPrevented: true. The pad Find bar opened (role=search), and its input took focus.
    • Control: a plain f typed into the field was not prevented.
    • Escape closed the bar and returned focus to the pad.
    • Limit: synthetic keys never open Safari's own Find bar. So this run cannot show that a real Cmd-F leaves Safari's bar shut. The prevented default is strong but indirect evidence.

    Seen, not a blocker: after Find closes on the read-only pad, the Edit button shows again. This is the known UX question.

    Left:

    • [maintainer] Press a real Cmd-F once on a pad in Safari. Pass: the pad Find bar opens, and Safari's own Find bar does not.
  13. HMarzban commented on Nov 9, 2026

    @HMarzban
    CollaboratorAuthor

    Maintainer check, 2026-11-09. A real Cmd-F in Safari on production (docs.plus/qa-hand-checks-1109): the pad Find bar opened, and Safari's own Find bar did not. That was the last leg. With the simulator row and the safaridriver run above, every leg has passed. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DesktopEditorFeatureMobileUIenhancementtiptap

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions