@@ -357,10 +357,16 @@ private void BreadcrumbBar_ItemDropDownFlyoutClosed(object sender, BreadcrumbBar
357
357
e . Flyout . Items . Clear ( ) ;
358
358
}
359
359
360
+ /// <summary>
361
+ /// Handles mode changes in the Omnibar control. This event can fire even when the Omnibar
362
+ /// already has focus (e.g., user switching from Command Palette to Search mode).
363
+ /// Updates the appropriate text property and populates suggestions based on the new mode.
364
+ /// </summary>
360
365
private async void Omnibar_ModeChanged ( object sender , OmnibarModeChangedEventArgs e )
361
366
{
362
367
if ( e . NewMode == OmnibarPathMode )
363
368
{
369
+ // Initialize with current working directory or fallback to home path
364
370
ViewModel . PathText = string . IsNullOrEmpty ( ContentPageContext . ShellPage ? . ShellViewModel ? . WorkingDirectory )
365
371
? Constants . UserEnvironmentPaths . HomePath
366
372
: ContentPageContext . ShellPage . ShellViewModel . WorkingDirectory ;
@@ -369,12 +375,14 @@ private async void Omnibar_ModeChanged(object sender, OmnibarModeChangedEventArg
369
375
}
370
376
else if ( e . NewMode == OmnibarCommandPaletteMode )
371
377
{
378
+ // Clear text and load command suggestions
372
379
ViewModel . OmnibarCommandPaletteModeText = string . Empty ;
373
380
374
381
await DispatcherQueue . EnqueueOrInvokeAsync ( ViewModel . PopulateOmnibarSuggestionsForCommandPaletteMode ) ;
375
382
}
376
383
else if ( e . NewMode == OmnibarSearchMode )
377
384
{
385
+ // Preserve existing search query or clear for new search
378
386
if ( ! ViewModel . InstanceViewModel . IsPageTypeSearchResults )
379
387
ViewModel . OmnibarSearchModeText = string . Empty ;
380
388
else
@@ -384,10 +392,16 @@ private async void Omnibar_ModeChanged(object sender, OmnibarModeChangedEventArg
384
392
}
385
393
}
386
394
395
+ /// <summary>
396
+ /// Handles focus state changes for the Omnibar control.
397
+ /// When focused: Updates Path Mode content (Path Mode has both focused/unfocused states).
398
+ /// When unfocused: Automatically switches back to Path Mode to display the BreadcrumbBar.
399
+ /// </summary>
387
400
private async void Omnibar_IsFocusedChanged ( Omnibar sender , OmnibarIsFocusedChangedEventArgs args )
388
401
{
389
402
if ( args . IsFocused )
390
403
{
404
+ // Path Mode needs special handling when gaining focus since it has an unfocused state
391
405
if ( Omnibar . CurrentSelectedMode == OmnibarPathMode )
392
406
{
393
407
ViewModel . PathText = string . IsNullOrEmpty ( ContentPageContext . ShellPage ? . ShellViewModel ? . WorkingDirectory )
@@ -396,19 +410,10 @@ private async void Omnibar_IsFocusedChanged(Omnibar sender, OmnibarIsFocusedChan
396
410
397
411
await DispatcherQueue . EnqueueOrInvokeAsync ( ViewModel . PopulateOmnibarSuggestionsForPathMode ) ;
398
412
}
399
- else if ( Omnibar . CurrentSelectedMode == OmnibarCommandPaletteMode )
400
- {
401
- ViewModel . OmnibarCommandPaletteModeText = string . Empty ;
402
-
403
- await DispatcherQueue . EnqueueOrInvokeAsync ( ViewModel . PopulateOmnibarSuggestionsForCommandPaletteMode ) ;
404
- }
405
- else if ( Omnibar . CurrentSelectedMode == OmnibarSearchMode )
406
- {
407
- await DispatcherQueue . EnqueueOrInvokeAsync ( ViewModel . PopulateOmnibarSuggestionsForSearchMode ) ;
408
- }
409
413
}
410
414
else
411
415
{
416
+ // When Omnibar loses focus, revert to Path Mode to display BreadcrumbBar
412
417
Omnibar . CurrentSelectedMode = OmnibarPathMode ;
413
418
}
414
419
}
0 commit comments