Skip to content

fix: the mode button switches modes while reading and keeps the text in place - #517

Merged
ScottKirvan merged 2 commits into
mainfrom
fix/mode-button-keeps-reading-mode
Oct 17, 2026
Merged

ScottKirvan merged 2 commits into
mainfrom
fix/mode-button-keeps-reading-mode

Conversation

@ScottKirvan

Copy link
Copy Markdown
Owner

Description

Scott's report: in reading mode, the markdown/plain-text button switched to edit mode. The intent is to see what you're reading in the other format, not to start editing. Switching also shouldn't scroll the page.

This replaces the rule from #484 ("while reading, a tap only brings editing back"), which came from a misreading of Scott's earlier request.

Now:

  • Reading mode: a tap switches between rendered markdown and plain text, and you stay in reading mode, with no focus and no keyboard.
  • Edit mode: unchanged. A tap switches modes, and the editor keeps focus with the keyboard up (fix: mode button keeps the keyboard up and only switches modes while editing #484's mousedown handling stays).
  • No scroll jump, in either mode: the text you were looking at stays where it was on screen. Switching plain-text mode changes line heights (headings, images, tables, hidden markers), so without this the view jumped; Chromium measured a 174px jump mid-document.

Code:

  • main.ts: the click handler always switches, and refocuses the editor only in edit mode.
  • editMode.ts: modeToggleAction is replaced by modeToggleLabel, so the button's label names the mode a tap switches to. "Start editing" is gone.
  • New scrollAnchor.ts: keepVisibleTextInPlace adds a scroll effect to the same dispatch as the switch.
  • Plain-text mode is still remembered across launches.

Spec (BEHAVIOR_SPEC §4) and both user-guide pages are updated. Judgment call ([Proposed — unconfirmed]): the text kept in place is the first line starting at or below the top of the visible area. In edit mode it's the cursor's line, if the cursor is on screen.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

On-device testing

  1. Open a long QuKi from the list (reading mode), scroll to the middle, tap the mode button. It switches to plain text, the keyboard doesn't appear, and the text you were looking at stays in place. Tap again: back to rendered, same place.
  2. Tap into the text (editing), tap the mode button. It switches, and the keyboard stays up.

How Has This Been Tested?

  • modeToggle.e2e.ts updated. The new reading-mode check failed on main ("a tap while reading must switch to plain text"). The scroll check, on a long QuKi with headings, images, lists, tables and quotes, in both directions, near the top, middle and end, in reading and edit mode, failed without the fix (a 174px jump) and passes with it. All 4 scenarios pass.
  • editMode.test.ts 17/17; npx tsc -b clean.
  • Full suite left to CI. Not tried on a device.

Checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

…in place

In reading mode a tap on the mode button now switches between rendered
and plain text and stays in reading mode, with no focus and no keyboard,
reversing the earlier rule that it only brought editing back. In edit
mode it still switches without taking focus from the editor.

The switch no longer scrolls: the first line starting at the top of the
visible area (the caret's line while editing) stays where it was on
screen. Without this the text jumped by the height change above it.
The mode button is now a plain two-state toggle between rendered and plain
text. Its icon shows the current format in reading and edit mode alike: the
markdown mark when rendered, the code icon in plain-text mode. The open-book
icon for reading mode is gone; reading vs. edit mode is no longer shown on
this button.
@ScottKirvan
ScottKirvan force-pushed the fix/mode-button-keeps-reading-mode branch from 0c5b615 to 08b1e08 Compare October 16, 2026 16:06
@ScottKirvan
ScottKirvan merged commit 621ef9b into main Oct 17, 2026
5 checks passed
@ScottKirvan
ScottKirvan deleted the fix/mode-button-keeps-reading-mode branch October 17, 2026 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant