Skip to content

Commit fd0ccd2

Browse files
authored
fix(material): prevent scroll on focus for radio and checkbox (#2562)
1 parent 0b9caa4 commit fd0ccd2

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/material/multicheckbox/src/multicheckbox.type.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,8 @@ export class FormlyFieldMultiCheckbox extends FieldType {
4444
this.formControl.markAsTouched();
4545
}
4646

47-
onContainerClick(event: MouseEvent): void {
48-
if (this.checkboxes.length) {
49-
this.checkboxes.first.focus();
50-
}
51-
super.onContainerClick(event);
52-
}
47+
// TODO: find a solution to prevent scroll on focus
48+
onContainerClick() {}
5349

5450
isChecked(option: any) {
5551
const value = this.formControl.value;

src/material/radio/src/radio.type.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,15 @@ export class FormlyFieldRadio extends FieldType implements AfterViewInit, OnDest
4747
? this.radioGroup.selected
4848
: this.radioGroup._radios.first;
4949

50-
radio.focus();
50+
radio._elementRef.nativeElement.focus({ preventScroll: true });
5151
});
5252
}
5353
});
5454
}
5555

56+
// TODO: find a solution to prevent scroll on focus
57+
onContainerClick() {}
58+
5659
ngOnDestroy() {
5760
this.focusObserver && this.focusObserver();
5861
}

0 commit comments

Comments
 (0)