-
-
Notifications
You must be signed in to change notification settings - Fork 250
Open
Description
Bug: perform_select_option
loses selection on single <select>
Package: Botasaurus Driver
File: botasaurus_driver/core/element.py
perform_select_option()
sets option.selected = true
on <option>
but does not update the parent <select>
's value
, causing selections on single <select>
elements to be lost when focus changes. Multi-select <select multiple>
is unaffected.
Proposed fix:
def perform_select_option(self):
"""
Marks an <option> as selected and properly updates the parent <select> element
to persist the selection.
Fixes a bug where single <select> elements lose their selected option
when focus moves to another input. Multi-select <select multiple> behavior
remains intact.
Usage: call this method on an Option element returned by select queries.
"""
if self.node_name == "OPTION":
self.apply(
"""
(o) => {
const select = o.parentElement;
if (select && select.multiple) {
o.selected = true;
} else {
select.value = o.value;
}
select.dispatchEvent(new Event('input', { bubbles: true }));
select.dispatchEvent(new Event('change', { bubbles: true }));
}
"""
)
Metadata
Metadata
Assignees
Labels
No labels