@@ -357,10 +357,16 @@ private void BreadcrumbBar_ItemDropDownFlyoutClosed(object sender, BreadcrumbBar
357357 e . Flyout . Items . Clear ( ) ;
358358 }
359359
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>
360365 private async void Omnibar_ModeChanged ( object sender , OmnibarModeChangedEventArgs e )
361366 {
362367 if ( e . NewMode == OmnibarPathMode )
363368 {
369+ // Initialize with current working directory or fallback to home path
364370 ViewModel . PathText = string . IsNullOrEmpty ( ContentPageContext . ShellPage ? . ShellViewModel ? . WorkingDirectory )
365371 ? Constants . UserEnvironmentPaths . HomePath
366372 : ContentPageContext . ShellPage . ShellViewModel . WorkingDirectory ;
@@ -369,12 +375,14 @@ private async void Omnibar_ModeChanged(object sender, OmnibarModeChangedEventArg
369375 }
370376 else if ( e . NewMode == OmnibarCommandPaletteMode )
371377 {
378+ // Clear text and load command suggestions
372379 ViewModel . OmnibarCommandPaletteModeText = string . Empty ;
373380
374381 await DispatcherQueue . EnqueueOrInvokeAsync ( ViewModel . PopulateOmnibarSuggestionsForCommandPaletteMode ) ;
375382 }
376383 else if ( e . NewMode == OmnibarSearchMode )
377384 {
385+ // Preserve existing search query or clear for new search
378386 if ( ! ViewModel . InstanceViewModel . IsPageTypeSearchResults )
379387 ViewModel . OmnibarSearchModeText = string . Empty ;
380388 else
@@ -384,10 +392,16 @@ private async void Omnibar_ModeChanged(object sender, OmnibarModeChangedEventArg
384392 }
385393 }
386394
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>
387400 private async void Omnibar_IsFocusedChanged ( Omnibar sender , OmnibarIsFocusedChangedEventArgs args )
388401 {
389402 if ( args . IsFocused )
390403 {
404+ // Path Mode needs special handling when gaining focus since it has an unfocused state
391405 if ( Omnibar . CurrentSelectedMode == OmnibarPathMode )
392406 {
393407 ViewModel . PathText = string . IsNullOrEmpty ( ContentPageContext . ShellPage ? . ShellViewModel ? . WorkingDirectory )
@@ -396,19 +410,10 @@ private async void Omnibar_IsFocusedChanged(Omnibar sender, OmnibarIsFocusedChan
396410
397411 await DispatcherQueue . EnqueueOrInvokeAsync ( ViewModel . PopulateOmnibarSuggestionsForPathMode ) ;
398412 }
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- }
409413 }
410414 else
411415 {
416+ // When Omnibar loses focus, revert to Path Mode to display BreadcrumbBar
412417 Omnibar . CurrentSelectedMode = OmnibarPathMode ;
413418 }
414419 }
0 commit comments