From 71185f91a826c0966fbcb6bed5ca9392163089e4 Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Sun, 12 Sep 2021 17:45:38 +0200 Subject: [PATCH] LibGUI: Enable/Disable the Open button on text change in FilePicker Prior this change, the button was updated on user selection change in the file view. This isn't quite right, as you could remove the text from the text box or (even worse) start typing a filename there and the button state wouldn't change. --- Userland/Libraries/LibGUI/FilePicker.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGUI/FilePicker.cpp b/Userland/Libraries/LibGUI/FilePicker.cpp index 380b207a4e..a98993333b 100644 --- a/Userland/Libraries/LibGUI/FilePicker.cpp +++ b/Userland/Libraries/LibGUI/FilePicker.cpp @@ -187,7 +187,11 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filen done(ExecCancel); }; - m_view->on_selection_change = [this, &ok_button] { + m_filename_textbox->on_change = [&] { + ok_button.set_enabled(!m_filename_textbox->text().is_empty()); + }; + + m_view->on_selection_change = [this] { auto index = m_view->selection().first(); auto& filter_model = (SortingProxyModel&)*m_view->model(); auto local_index = filter_model.map_to_source(index); @@ -199,7 +203,6 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filen } else if (m_mode != Mode::Save) { m_filename_textbox->clear(); } - ok_button.set_enabled(!m_filename_textbox->text().is_empty()); }; m_view->on_activation = [this](auto& index) {