Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 6 additions & 5 deletions src/Files.App.Controls/Omnibar/Omnibar.Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ private void AutoSuggestBox_GettingFocus(UIElement sender, GettingFocusEventArgs

private void AutoSuggestBox_LosingFocus(UIElement sender, LosingFocusEventArgs args)
{
if (args.NewFocusedElement is Button && IsModeButtonPressed)
{
IsModeButtonPressed = false;
args.TryCancel();
// Prevent the TextBox from losing focus when the ModeButton is focused
if (args.NewFocusedElement is not Button button ||
args.InputDevice is FocusInputDeviceKind.Keyboard ||
button.Tag?.ToString() != "ModeButton")
return;
}

args.TryCancel();
}

private void AutoSuggestBox_GotFocus(object sender, RoutedEventArgs e)
Expand Down
3 changes: 0 additions & 3 deletions src/Files.App.Controls/Omnibar/Omnibar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ public partial class Omnibar : Control

private WeakReference<UIElement?> _previouslyFocusedElement = new(null);

// NOTE: This is a workaround to keep Omnibar's focus on a mode button being clicked
internal bool IsModeButtonPressed { get; set; }

// Events

public event TypedEventHandler<Omnibar, OmnibarQuerySubmittedEventArgs>? QuerySubmitted;
Expand Down
2 changes: 2 additions & 0 deletions src/Files.App.Controls/Omnibar/Omnibar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,13 @@
<Button
x:Name="PART_ModeButton"
Width="{StaticResource OmnibarModeDefaultClickAreaWidth}"
Height="{StaticResource OmnibarModeDefaultHeight}"
Margin="1"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="0"
CornerRadius="{TemplateBinding CornerRadius}"
Tag="ModeButton"
ToolTipService.ToolTip="{Binding ModeName, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}">
<Button.Resources>
<SolidColorBrush x:Key="ButtonBackgroundPointerOver" Color="{ThemeResource SubtleFillColorSecondary}" />
Expand Down
1 change: 0 additions & 1 deletion src/Files.App.Controls/Omnibar/OmnibarMode.Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ private void ModeButton_Click(object sender, RoutedEventArgs e)
if (_ownerRef is null || _ownerRef.TryGetTarget(out var owner) is false || owner.CurrentSelectedMode == this)
return;

owner.IsModeButtonPressed = true;
owner.CurrentSelectedMode = this;
}
}
Expand Down
Loading