1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:38:12 +00:00

LibWeb: Make <input type=checkbox> fire click events when clicked :^)

This makes React react to checkboxes. Apparently they ignore the
"change" event in favor of "click" on checkboxes. This is a
compatibility hack for IE8.
This commit is contained in:
Andreas Kling 2022-02-17 13:31:09 +01:00
parent 2660795bcf
commit 246c31ccf6
3 changed files with 13 additions and 1 deletions

View file

@ -62,8 +62,10 @@ void CheckBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position
if (!is_inside_node_or_label)
is_inside_node_or_label = Label::is_inside_associated_label(*this, position);
if (is_inside_node_or_label)
if (is_inside_node_or_label) {
dom_node().did_click_checkbox({});
dom_node().set_checked(!dom_node().checked(), HTML::HTMLInputElement::ChangeSource::User);
}
m_being_pressed = false;
m_tracking_mouse = false;
@ -103,6 +105,7 @@ void CheckBox::handle_associated_label_mouseup(Badge<Label>)
// NOTE: Changing the checked state of the DOM node may run arbitrary JS, which could disappear this node.
NonnullRefPtr protect = *this;
dom_node().did_click_checkbox({});
dom_node().set_checked(!dom_node().checked(), HTML::HTMLInputElement::ChangeSource::User);
m_being_pressed = false;
}