Skip to content

fix(chooser): select filename stem on initial save presentation - #1898

Merged
l0gicgate merged 1 commit into
mainfrom
fix/1897-save-filename-stem-selection
Oct 27, 2026
Merged

l0gicgate merged 1 commit into
mainfrom
fix/1897-save-filename-stem-selection

Conversation

@JoeJoeflyn

@JoeJoeflyn JoeJoeflyn commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Select only the file stem (up to the last dot) when presenting a SaveFile chooser with a suggested filename, allowing users to immediately replace the filename while preserving the extension.

Use grab_focus_without_selecting and preserve the stem selection during post-presentation idle focus restoration so that GTK's GtkEntry focus handler does not reset the selection to all text.

Visual evidence

image

How to test

  1. Open a SaveFile portal request with current_name set to report.draft.pdf (e.g. saving/downloading a file).
  2. Observe the selection in the filename entry upon dialog presentation.

Expected result:
The name field has keyboard focus and only report.draft is selected, leaving .pdf unselected.

Related issue

Closes #1897

Select only the filename stem up to the last dot when presenting a SaveFile
chooser with a suggested name, allowing users to immediately replace the
name while preserving the extension.

Use grab_focus_without_selecting and preserve the stem selection during
post-presentation idle focus restoration so that GTK's entry focus handler
does not select all text.
@github-actions github-actions Bot added the fix label Oct 26, 2026
@l0gicgate

Copy link
Copy Markdown
Contributor

Review and cleanup

Merged main: nothing to merge. The branch already contains main at be3343a59 (chore: release v1.1.1), so no commits were pushed.

Review against the description and #1897

  • Stem-only selection when a suggested name is shown: confirmed. The build-time selection, the post-present focus and the idle restore all go through select_name_stem (rename_stem_end, the same rule rename uses). report.draft.pdf selects 0..12.
  • The idle restore no longer re-selects everything: confirmed. It now calls grab_focus_without_selecting on the name field instead of widget.grab_focus(), which made GtkText select all.
  • Keyboard focus stays on the name field: confirmed. Outside 10x mode the idle callback refocuses the field, which is what the old initial_focus path did on this route.
  • No review comments to reconcile.

Tests

  • ui::chooser::tests::keyboard::save_file_initial_name_selection_stops_before_the_dot is kept. It is behavioural and catches the bug: with only the idle-restore change reverted, it fails with left: Some((0, 16)). Nothing tautological was added.

Comment audit: the PR adds no comments.

Validation

  • ./scripts/test-headless.py ui::chooser::tests::keyboard: 17 passed
  • ./scripts/test-headless.py ui::chooser::: 65 passed, 0 failed
  • Mutation check described above: the new test fails without the idle fix and passes with it
  • Not run locally: quality.sh fmt / clippy, because the review changed no code. CI's Format, lint, and test and Quality build and lint are green on this exact head. QA scenarios were not run either; none cover the save-name selection.

Non-blocking notes

  • In 10x mode, Tab from the header into the name field (install_shortcuts) now selects the stem instead of the whole name. That goes slightly beyond the initial presentation the issue describes, but it matches r/edit_name. No test covers it.
  • Two other paths still select the whole name: the arrow-key focus-recovery fallback (filename.grab_focus() in install_shortcuts) and the refocus after an invalid name in accept_save_file. Both are reasonable as they are and outside this PR's scope.

CI: all checks green (QA scenarios skipped by workflow) as of 2026-10-26.

@l0gicgate
l0gicgate merged commit c8d754e into main Oct 27, 2026
13 checks passed
@l0gicgate
l0gicgate deleted the fix/1897-save-filename-stem-selection branch October 27, 2026 04:12
wmfeht added a commit to wmfeht/strata-feature-map that referenced this pull request Oct 28, 2026
Sync lgse/strata#1898–#1908: Save stem selection, multi-word global search, preview fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(chooser): select filename stem on initial save presentation

2 participants