1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:37:35 +00:00

Browser: Disallow empty URLs in the bookmark editor

When an empty URL is given to `BookmarkEditor`, it will now
disable the button that saves the bookmark change since an empty
URL is an invalid URL.
This commit is contained in:
Kemal Zebari 2023-01-20 11:21:40 -08:00 committed by Jelle Raaijmakers
parent 24ab91f4d3
commit 5d7331b4ed

View file

@ -58,15 +58,19 @@ private:
m_title_textbox->set_focus(true);
m_title_textbox->select_all();
m_url_textbox = *widget->find_descendant_of_type_named<GUI::TextBox>("url_textbox");
m_url_textbox->set_text(url);
auto& ok_button = *widget->find_descendant_of_type_named<GUI::Button>("ok_button");
ok_button.on_click = [this](auto) {
done(ExecResult::OK);
};
ok_button.set_default(true);
m_url_textbox = *widget->find_descendant_of_type_named<GUI::TextBox>("url_textbox");
m_url_textbox->set_text(url);
m_url_textbox->on_change = [this, &ok_button]() {
auto has_url = !m_url_textbox->text().is_empty();
ok_button.set_enabled(has_url);
};
auto& cancel_button = *widget->find_descendant_of_type_named<GUI::Button>("cancel_button");
cancel_button.on_click = [this](auto) {
done(ExecResult::Cancel);