Skip to content

PDFileExplorer: NavigateToItemAsync, and handler failures go to ExceptionHandler - #360

Merged
rolandbanks merged 1 commit into
mainfrom
feature/file-explorer-navigate-and-select
Nov 11, 2026
Merged

rolandbanks merged 1 commit into
mainfrom
feature/file-explorer-navigate-and-select

Conversation

@rolandbanks

Copy link
Copy Markdown
Contributor

Summary

Two changes to PDFileExplorer, for the Magic Suite Files search (MS-23441), and a hardening pass on the explorer and its tree.

Open a search result without stepping through every folder

NavigateToAsync(path) selects the root and then each folder on the way down, so the table loads and redraws once per
folder and FolderChanged is raised for each. Opening a deep result visibly walks through every folder, and the item
itself is never selected.

  • PDFileExplorer.NavigateToItemAsync(itemPath) loads the folders above the item into the tree without opening
    them, opens the item's folder once (one table load, one FolderChanged), selects the item as a click would and
    scrolls it into view. It returns false, leaving the deepest folder found open, when the item is not there. A later
    call supersedes one that is still loading. NavigateToAsync is unchanged.
  • PDTree.LoadChildNodesAsync(node) loads a node's children without expanding it or redrawing the tree.
    ToggleNodeIsExpandedAsync now uses it, with the same behaviour as before.
  • PDTable.ScrollItemIntoViewAsync(key) scrolls a row into view, no further than needed, matching keys such as file
    paths that are not valid CSS identifiers.

Splitter height without the toolbar

With ShowToolbar="false" the toolbar was only hidden, and the splitter kept calc(100% - 50px). The explorer now has
the pdfe-no-toolbar class in that case, and its splitter takes the full height. With the toolbar shown nothing
changes. main.scss, main.css and main.min.css were edited by hand to match.

Failures no longer end the circuit

  • PDFileExplorer and PDTree re-implement IHandleEvent through a new internal ComponentExceptionGuard. Events
    are handled exactly as ComponentBase does, rendering before and after, but when the application gives an
    ExceptionHandler
    a failure in an event handler is passed to it instead of ending the Blazor circuit. Without
    one, a failure is thrown as before.
    The explorer passes its own handler to its tree and table only when the
    application gave one, so that without one the tree does not swallow a failure.
  • PDTree's click timer now only hands the click to the dispatcher, where the clicks are counted. Before, a failure
    in the selection, including in the application's handlers, vanished in an unobserved task.
  • PDFileExplorer's first render: the touch check is inside the try, and a failing UpdateToolbarState handler
    is passed on.
  • PDTable's async void pager handlers pass a failing PageChanged or PageSizeChanged handler to
    ExceptionHandler.

Behaviour change: an application that already passes an ExceptionHandler to PDFileExplorer or PDTree now
receives event failures there, where before they ended the circuit.

Not changed: PDTable has no guard of its own, its slow-click edit timer still starts the edit on a background task, and
public methods such as NavigateToAsync still throw to their caller.

Demo and docs

A Show a file box on the PDFileExplorer demo page (preset to /Library/Templates/word_template.docx), and a
Methods table in the explorer's documentation. PackageReleaseNotes gains a paragraph after the unreleased PDChat
notes.

Testing

  • 9 new bUnit tests: navigating to an item (deep, a folder, missing item, missing folder, blank or root, scrolling
    fails, a later call supersedes), LoadChildNodesAsync, ScrollItemIntoViewAsync, the no-toolbar class, failing
    handlers passed to ExceptionHandler in the explorer, the tree's click and keyboard, the explorer's first render and
    the table's pager, and, for the explorer and the tree, that a failure still throws without an ExceptionHandler.
  • Solution build clean (warnings are errors); full suite 4,739 passed, run twice.
  • Not yet checked in a browser.

🤖 Generated with Claude Code

…lects it; handler failures go to ExceptionHandler

- NavigateToItemAsync(itemPath) loads the folders above an item into the tree without opening them, opens the
  item's folder once (one table load, one FolderChanged), selects the item and scrolls it into view. It returns
  false, with the deepest folder found open, when the item is not there, and a later call supersedes one still
  loading. NavigateToAsync is unchanged.
- PDTree.LoadChildNodesAsync loads a node's children without expanding it or redrawing the tree;
  ToggleNodeIsExpandedAsync now uses it.
- PDTable.ScrollItemIntoViewAsync scrolls a row into view by its key, no further than needed.
- Without its toolbar the explorer has the pdfe-no-toolbar class and its splitter takes the full height.
- PDFileExplorer and PDTree handle events through ComponentExceptionGuard: given an ExceptionHandler, a failure in
  an event handler is passed to it instead of ending the Blazor circuit; without one it is thrown as before. The
  explorer passes its own handler to its tree and table only when the application gave one. The tree's click timer
  now only hands the click to the dispatcher, the explorer's first render passes a failing toolbar state handler
  on, and PDTable's async void pager handlers pass a failure to ExceptionHandler.
- Demo: a "Show a file" box on the PDFileExplorer page, and a Methods table in its documentation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rolandbanks
rolandbanks merged commit d48ce5a into main Nov 11, 2026
1 of 4 checks passed
@rolandbanks
rolandbanks deleted the feature/file-explorer-navigate-and-select branch November 11, 2026 02:52
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 4 medium

Alerts:
⚠ 4 issues (≤ 0 issues of at least minor severity)

Results:
4 new issues

Category Results
BestPractice 3 medium
Complexity 1 medium

View in Codacy

🟢 Metrics 64 complexity · 6 duplication

Metric Results
Complexity 64
Duplication 6

View in Codacy

AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

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