Fixes #5099 - Preserve filename on FileDialog table navigation#5408
Merged
Conversation
Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/0f74e966-6173-4a3e-a6c3-9232b2e86fa0 Co-authored-by: tig <585482+tig@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix FileDialog PreserveFilenameOnDirectoryChanges behavior
Preserve filename on FileDialog table navigation
May 25, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates FileDialog’s TableView navigation to avoid overwriting a user-typed filename when directory changes trigger an internal PushState, particularly when PreserveFilenameOnDirectoryChanges is enabled.
Changes:
- Guard
TableViewOnValueChangedwith_pushingStateto prevent re-entrant/refresh-driven selection changes from rewritingPath. - Add an integration regression test covering “Enter on directory” and then “Enter on ..” navigation while preserving the typed filename.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Tests/IntegrationTests/FluentTests/FileDialogTests.cs | Adds a regression integration test for SaveDialog TableView Enter navigation + filename preservation. |
| Terminal.Gui/Views/FileDialogs/FileDialog.TableView.cs | Prevents ValueChanged side effects during internal state pushes by checking _pushingState. |
Move AllowedTypes and PreserveFilenameOnDirectoryChanges assignments into the factory lambda so they are set before EndInit() initializes CurrentFilter and the type dropdown. Previously these were set in .Then() which runs after EndInit(), meaning the filter was never applied to the initial listing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
BDisp
approved these changes
May 25, 2026
Member
|
This needs @tznind's approval since he reported it. |
tznind
approved these changes
May 25, 2026
Collaborator
|
It would be good if the copilot first committed test so we could see failure then did fix in followup commit to see it fixed with no further test change. Even if the pr were then squashed Looks good though. |
This was referenced May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes/Todos
PreserveFilenameOnDirectoryChangesintact when TableView navigation triggers an internalPushState.TableViewOnValueChangedwhile_pushingStateis active so table refreshes do not overwrite the typed filename with the first file in the newly opened directory...navigates back to the parent directory instead of closing the dialog.Pull Request checklist:
CTRL-K-Dto automatically reformat your files before committing.dotnet testbefore commit///style comments)