Skip to content

Commit dcaed67

Browse files
authored
Merge pull request #2691 from zerline/focus-fix2
Focus/blur on a RadioButtons widget.
2 parents c4775b6 + 729f7ba commit dcaed67

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/controls/src/widget_selection.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,21 @@ class RadioButtonsView extends DescriptionView {
403403
this.touch();
404404
}
405405

406+
/**
407+
* Handle message sent to the front end.
408+
*/
409+
handle_message(content: any) {
410+
if (content.do == 'focus') {
411+
const firstItem = this.container.firstElementChild as HTMLElement;
412+
firstItem.focus();
413+
} else if (content.do == 'blur') {
414+
for (let i = 0; i < this.container.children.length; i++) {
415+
const item = this.container.children[i] as HTMLElement;
416+
item.blur();
417+
}
418+
}
419+
}
420+
406421
container: HTMLDivElement;
407422
}
408423

0 commit comments

Comments
 (0)