mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:57:34 +00:00
LibGUI: Don't update ComboBox text when model index is invalid
Without ENABLE_TIME_ZONE_DATA the user is able to update the time zone selection when using "on_mousewheel" or "on_{up,down}_pressed" even though UTC is supposed to be the only option. Due to an invalid model index, the selection is set to "[null]". Prior to this patch, the ComboBox text in "selection_updated" is set at each call.
This commit is contained in:
parent
3b733ff7bc
commit
7e10f76021
1 changed files with 5 additions and 4 deletions
|
@ -177,12 +177,13 @@ void ComboBox::navigate_relative(int delta)
|
||||||
|
|
||||||
void ComboBox::selection_updated(ModelIndex const& index)
|
void ComboBox::selection_updated(ModelIndex const& index)
|
||||||
{
|
{
|
||||||
if (index.is_valid())
|
if (index.is_valid()) {
|
||||||
m_selected_index = index;
|
m_selected_index = index;
|
||||||
else
|
auto new_value = index.data().to_deprecated_string();
|
||||||
|
m_editor->set_text(new_value);
|
||||||
|
} else {
|
||||||
m_selected_index.clear();
|
m_selected_index.clear();
|
||||||
auto new_value = index.data().to_deprecated_string();
|
}
|
||||||
m_editor->set_text(new_value);
|
|
||||||
if (!m_only_allow_values_from_model)
|
if (!m_only_allow_values_from_model)
|
||||||
m_editor->select_all();
|
m_editor->select_all();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue