diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 4ddf49914b7..c40047a21d8 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -837,6 +837,16 @@ void HTMLInputElement::create_text_input_shadow_tree() MUST(up_button->set_inner_html(""sv)); MUST(element->append_child(up_button)); + auto mouseup_callback_function = JS::NativeFunction::create( + realm(), [this](JS::VM&) { + commit_pending_changes(); + return JS::js_undefined(); + }, + 0, "", &realm()); + auto mouseup_callback = realm().heap().allocate_without_realm(*mouseup_callback_function, Bindings::host_defined_environment_settings_object(realm())); + DOM::AddEventListenerOptions mouseup_listener_options; + mouseup_listener_options.once = true; + auto up_callback_function = JS::NativeFunction::create( realm(), [this](JS::VM&) { MUST(step_up()); @@ -844,8 +854,9 @@ void HTMLInputElement::create_text_input_shadow_tree() return JS::js_undefined(); }, 0, "", &realm()); - auto up_callback = realm().heap().allocate_without_realm(*up_callback_function, Bindings::host_defined_environment_settings_object(realm())); - up_button->add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), up_callback)); + auto step_up_callback = realm().heap().allocate_without_realm(*up_callback_function, Bindings::host_defined_environment_settings_object(realm())); + up_button->add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), step_up_callback)); + up_button->add_event_listener_without_options(UIEvents::EventNames::mouseup, DOM::IDLEventListener::create(realm(), mouseup_callback)); // Down button auto down_button = MUST(DOM::create_element(document(), HTML::TagNames::button, Namespace::HTML)); @@ -863,8 +874,9 @@ void HTMLInputElement::create_text_input_shadow_tree() return JS::js_undefined(); }, 0, "", &realm()); - auto down_callback = realm().heap().allocate_without_realm(*down_callback_function, Bindings::host_defined_environment_settings_object(realm())); - down_button->add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), down_callback)); + auto step_down_callback = realm().heap().allocate_without_realm(*down_callback_function, Bindings::host_defined_environment_settings_object(realm())); + down_button->add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), step_down_callback)); + down_button->add_event_listener_without_options(UIEvents::EventNames::mouseup, DOM::IDLEventListener::create(realm(), mouseup_callback)); } }