Skip to content

Fixes #5200 - Prevent FileDialog Enter navigation from selecting the first file#5405

Merged
tig merged 3 commits into
developfrom
copilot/test-file-dialog-folder-bug
May 25, 2026
Merged

Fixes #5200 - Prevent FileDialog Enter navigation from selecting the first file#5405
tig merged 3 commits into
developfrom
copilot/test-file-dialog-folder-bug

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 25, 2026

Proposed Changes/Todos

The file dialog was rewriting Path to the first row in the newly opened directory when Enter was used from the table, which made folder navigation behave like an implicit file selection. This change keeps Enter-driven directory navigation on the opened directory so the file list is shown without auto-selecting the first file.

  • Regression coverage
    • Added a focused FileDialogResultTests case for Enter on a directory row in the table.
  • State transition fix
    • Suppressed TableViewOnValueChanged (...) path synchronization while FileDialog is internally pushing a new directory state.
    • This prevents the internal reset to row 0 from overwriting the just-opened directory path.
  • Behavior after Enter navigation
    • Path remains on the opened directory.
    • The new directory contents are displayed and available for selection.
if (_pushingState || !_tableView.HasFocus || _tableView.Value is null || _tableView.Table?.Rows == 0)
{
    return;
}

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

Copilot AI assigned Copilot and tig May 25, 2026
Copilot AI linked an issue May 25, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Test file dialog open folder bug with Enter key Prevent FileDialog Enter navigation from selecting the first file May 25, 2026
Copilot finished work on behalf of tig May 25, 2026 01:26
Copilot AI requested a review from tig May 25, 2026 01:26
@tig tig marked this pull request as ready for review May 25, 2026 03:29
@tig tig requested a review from Copilot May 25, 2026 03:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an unintended FileDialog behavior where pressing Enter on a directory row in the file list could rewrite Path to the first row of the newly opened directory (making directory navigation behave like an implicit file selection). The change prevents TableViewOnValueChanged from synchronizing Path while FileDialog is internally pushing a new directory state.

Changes:

  • Suppress TableViewOnValueChanged path synchronization when _pushingState is true to avoid overwriting the just-opened directory path during internal navigation.
  • Add a regression unit test verifying that Enter-accepting a directory from the table keeps Path on the opened directory after navigation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Tests/UnitTestsParallelizable/Views/FileDialogResultTests.cs Adds a regression test covering Enter navigation into a directory from the table view.
Terminal.Gui/Views/FileDialogs/FileDialog.TableView.cs Guards TableViewOnValueChanged with _pushingState to prevent path rewrites during internal state transitions.

Comment thread Tests/UnitTestsParallelizable/Views/FileDialogResultTests.cs Outdated
@tig tig changed the title Prevent FileDialog Enter navigation from selecting the first file Fixes #5200 - Prevent FileDialog Enter navigation from selecting the first file May 25, 2026
- Replace hard-coded row index with FindRowByName helper that searches
  by cell content, decoupling the test from TableView ordering internals
- Use Assert.EndsWith for path validation to be platform-independent
- Store path before accept and compare after, testing the actual regression
  behavior without coupling to platform-specific path formats

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tig tig requested review from BDisp and tznind May 25, 2026 19:21
@tig
Copy link
Copy Markdown
Member

tig commented May 25, 2026

This needs @tznind's approval since he reported it.

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.

File Dialog open folder bug with Enter key

5 participants