Skip to content

[TF2] fix(econ): handle escape in combobox #1917

Open
SanyaKor wants to merge 1 commit into
ValveSoftware:masterfrom
SanyaKor:combobox-ui-fix
Open

[TF2] fix(econ): handle escape in combobox #1917
SanyaKor wants to merge 1 commit into
ValveSoftware:masterfrom
SanyaKor:combobox-ui-fix

Conversation

@SanyaKor
Copy link
Copy Markdown

Description

While playing TF2 casual, I noticed an issue with backpack combo overlay dialogs. Here is a video of the issue:

bug1.mp4

And if u play around with that it can gets even worse.

bug2.mp4

The Select Style window did not have complete Escape handling, especially for the combo box dropdown state.

I compared this behavior with CConfirmDialog in game/client/econ/confirm_dialog.cpp. Like CComboBoxBackpackOverlayDialogBase, CConfirmDialog is also based on vgui::EditablePanel. CConfirmDialog handles Escape by overriding the EditablePanel keyboard input method, OnKeyCodeTyped, and routing it through its normal cancel command:

void CConfirmDialog::OnKeyCodeTyped( vgui::KeyCode code )
{
	if ( code == KEY_ESCAPE )
	{
		OnCommand( "cancel" );
	}
}

CComboBoxBackpackOverlayDialogBase did not fully handle the same case. Adding Escape handling to the base overlay fixes the case where the overlay itself has focus. However, vgui::ComboBox opens an internal vgui::Menu for its dropdown, and that menu takes focus while the dropdown is open. Because of that, Escape never reaches the parent overlay while the dropdown is active.

This fix handles both focus paths:

  • CComboBoxBackpackOverlayDialogBase now maps Escape to OnCommand("cancel"), similar to CConfirmDialog.
  • The combo box dropdown uses a small custom menu that catches Escape while the dropdown has focus.
  • That menu posts a ComboBoxEscape action signal back to the parent overlay.
  • The parent overlay handles ComboBoxEscape by calling the same OnCommand("cancel") path.

Here is the result after the fix:

fixed.mp4

Now Escape consistently closes the Select Style dialog whether focus is on the overlay itself or inside the opened combo box dropdown. The existing style selection/apply logic is unchanged.

This base combo overlay is not only used by Select Style (CStyleSelectDialog). It is also used by the refurbish/restoration dialog (CRefurbishItemDialog) and by the strange part restriction selection dialog (CSelectStrangePartToRestrictDialog). The refurbish dialog can hit the same issue: for example, try restoring/removing a customization from a Strange weapon that has more than one Strange part, open the dropdown, and press Escape. The dropdown can close while the parent overlay remains open, which can leave the UI in the same awkward state.

Example of issue with restoration

otherbug.mp4

I did not find an in-game issue with the strange part restriction flow (CSelectStrangePartToRestrictDialog) during testing, but it shares the same base dropdown behavior. I do not expect forwarding Escape through the normal cancel path to break it. If a specific derived dialog ever needs different Escape behavior, it can override the relevant handler with an empty or custom implementation.

@SanyaKor SanyaKor changed the title fix(econ): handle escape in combo box overlay dropdowns [TF2] fix(econ): handle escape in combobox May 11, 2026
@SanyaKor
Copy link
Copy Markdown
Author

Note: I also found another related input issue. If you open Select Style or the refurbish/restoration dropdown, press Escape to return to gameplay, and then press the chat/team chat key (U in my test), the UI input state can break badly. After that, backpack, loadout, and team selection inputs may stop responding, and in the worst case the game cannot be closed normally without Alt+F4. This looks related to the same missing/incorrect Escape handling leaving the UI in an inconsistent focus state.

input-bug-2.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant