Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/blitz-dom/src/events/mouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ pub(crate) fn handle_click(
continue;
};

let is_focusable = el.is_focussable;

let disabled = el.attr(local_name!("disabled")).is_some();
if disabled {
break 'matched true;
Expand All @@ -293,6 +295,17 @@ pub(crate) fn handle_click(
break 'matched true;
}

if is_focusable {
generate_focus_events(
doc,
&mut |doc| {
doc.set_focus_to(node_id);
},
dispatch_event,
);
break 'matched true;
}

match el.name.local {
local_name!("input") if el.attr(local_name!("type")) == Some("checkbox") => {
let is_checked = BaseDocument::toggle_checkbox(el);
Expand Down
5 changes: 5 additions & 0 deletions packages/blitz-dom/src/mutator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ impl DocumentMutator<'_> {

element.attrs.set(name.clone(), value);

// Update focusability when tabindex or disabled changes
if *&name.local == local_name!("tabindex") || *&name.local == local_name!("disabled") {
element.flush_is_focussable();
}

let tag = &element.name.local;
let attr = &name.local;

Expand Down