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
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource {x:Static vsui:EnvironmentColors.ComboBoxMouseOverBorderBrushKey}}" />
<Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource {x:Static vsui:EnvironmentColors.CommandBarTextHoverBrushKey}}" />
</Trigger>
<Trigger Property="IsKeyboardFocusWithin" Value="true">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static vsui:EnvironmentColors.ComboBoxMouseOverBackgroundGradientBrushKey}}"/>
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource {x:Static vsui:EnvironmentColors.ComboBoxMouseOverBorderBrushKey}}" />
<Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource {x:Static vsui:EnvironmentColors.CommandBarTextHoverBrushKey}}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static vsui:EnvironmentColors.ComboBoxMouseOverBackgroundGradientBrushKey}}"/>
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource {x:Static vsui:EnvironmentColors.ComboBoxMouseOverBorderBrushKey}}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ internal SmartRenameUserInputComboBox(RenameFlyoutViewModel viewModel)
});

_smartRenameViewModel.SuggestedNames.CollectionChanged += SuggestedNames_CollectionChanged;
AddHandler(Keyboard.GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(OnItemGotKeyboardFocus), handledEventsToo: true);
}

public int TextSelectionStart
Expand Down Expand Up @@ -101,6 +102,16 @@ private void ComboBox_GotKeyboardFocus(object sender, KeyboardFocusChangedEventA
e.Handled = true;
}

private void OnItemGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
{
// When a ComboBoxItem receives keyboard focus (e.g., via Tab navigation),
// update the ComboBox selection to match the focused item
if (e.NewFocus is ComboBoxItem comboBoxItem && comboBoxItem.DataContext != null)
{
SelectedItem = comboBoxItem.DataContext;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we wouldn't want to select the item until the user hits enter or space.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Joey, "Seems like we wouldn't want to select the item until the user hits enter or space." is not consistent with current behavior.

Without this event handler, the highlighted item does not get previewed. Then, upon pressing Enter, it's not going to be committed (because it's not inserted into the TextBox)
{400AC562-8580-41E3-9788-821ECA0BFF14}

That's not how we currently handle up/down, where the item is selected, inserted into the TextBox, and ultimately used for rename on Enter.
{6C5EB5EE-6B5F-44FC-8C8B-A4618831BC10}

The above code makes the TAB selection behave the same way as Up/Down selection ^

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sounds good. Thanks @AmadeusW!

}
}

private void SuggestionsPanelScrollViewer_MouseDoubleClick(object sender, MouseEventArgs e)
{
_baseViewModel.Submit();
Expand Down
Loading