From 98700eee43bbb236cd8834c33e11b6c5e2ce23d0 Mon Sep 17 00:00:00 2001 From: kos Date: Sun, 16 Nov 2025 02:43:26 +0100 Subject: [PATCH] Fix #14755: Remove clicked type selection when not visible --- src/picker_gui.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/picker_gui.cpp b/src/picker_gui.cpp index 4c4bbc5ae0..d4799b3fb8 100644 --- a/src/picker_gui.cpp +++ b/src/picker_gui.cpp @@ -693,6 +693,7 @@ void PickerWindow::BuildPickerTypeList() if (!this->has_type_picker) return; this->GetWidget(WID_PW_TYPE_MATRIX)->SetCount(static_cast(this->types.size())); + this->EnsureSelectedTypeIsVisible(); } void PickerWindow::EnsureSelectedTypeIsValid() @@ -729,9 +730,11 @@ void PickerWindow::EnsureSelectedTypeIsVisible() int index = this->callbacks.GetSelectedType(); auto it = std::ranges::find_if(this->types, [class_index, index](const auto &item) { return item.class_index == class_index && item.index == index; }); - if (it == std::end(this->types)) return; + int pos = -1; + if (it != std::end(this->types)) { + pos = static_cast(std::distance(std::begin(this->types), it)); + } - int pos = static_cast(std::distance(std::begin(this->types), it)); this->GetWidget(WID_PW_TYPE_MATRIX)->SetClicked(pos); }