Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Files.App.Controls/Omnibar/Omnibar.Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ private void AutoSuggestBox_LostFocus(object sender, RoutedEventArgs e)

IsFocused = false;
IsFocusedChanged?.Invoke(this, new(IsFocused));

// Workaround to prevent an issue where if the window loses focus and then regains focus,
// the AutoSuggestBox will regain focus and the suggestions popup will open again.
if (element is TextBox)
{
_previouslyFocusedElement.TryGetTarget(out var previouslyFocusedElement);
previouslyFocusedElement?.Focus(FocusState.Programmatic);
}
}

private async void AutoSuggestBox_KeyDown(object sender, KeyRoutedEventArgs e)
Expand Down
2 changes: 0 additions & 2 deletions src/Files.App/Data/Contracts/IAddressToolbarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,5 @@ public interface IAddressToolbarViewModel
public event ItemDraggedOverPathItemEventHandler ItemDraggedOverPathItem;

public event EventHandler RefreshWidgetsRequested;

public void SwitchToSearchMode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -602,16 +602,26 @@ public void SwitchToCommandPaletteMode()
OmnibarCurrentSelectedModeName = OmnibarPaletteModeName;
}

public void SwitchToSearchMode()
public async Task SwitchToSearchMode()
{
// If the Omnibar is already focused such as when the user initiates a search via the Command Palette,
// add a short delay to allow the Command Palette to fully close before switching modes.
var omnibar = AddressToolbar?.FindDescendant("Omnibar") as Omnibar;
if (omnibar is not null && omnibar.IsFocused)
await Task.Delay(100);

OmnibarCurrentSelectedModeName = OmnibarSearchModeName;
}

public void SwitchToPathMode()
public async Task SwitchToPathMode()
{
OmnibarCurrentSelectedModeName = OmnibarPathModeName;

// If the Omnibar is already focused such as when the user initiates the Edit Path action via the
// Command Palette, add a short delay to allow the Command Palette to fully close before switching modes.
var omnibar = AddressToolbar?.FindDescendant("Omnibar") as Omnibar;
if (omnibar is not null && omnibar.IsFocused)
await Task.Delay(100);

OmnibarCurrentSelectedModeName = OmnibarPathModeName;
omnibar?.Focus(FocusState.Programmatic);
omnibar.IsFocused = true;
}
Expand Down Expand Up @@ -997,8 +1007,7 @@ await Task.Run(() =>
HotKeys = command.HotKeys,
SearchText = OmnibarCommandPaletteModeText,
})
.Where(item => item.Text != Commands.OpenCommandPalette.Description.ToString()
&& item.Text != Commands.EditPath.Description.ToString());
.Where(item => item.Text != Commands.OpenCommandPalette.Description.ToString());
});

newSuggestions.AddRange(suggestionItems);
Expand Down
Loading