From 417f0d17c9c5188f98bc0d1eb76fc5d03518916a Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Wed, 28 Dec 2022 17:21:11 -0500 Subject: [PATCH] don't scroll when refocusing --- src/components/select/select.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/select/select.ts b/src/components/select/select.ts index 26b5522b0..7e9941516 100644 --- a/src/components/select/select.ts +++ b/src/components/select/select.ts @@ -235,7 +235,7 @@ export default class SlSelect extends ShoelaceElement implements ShoelaceFormCon event.preventDefault(); event.stopPropagation(); this.hide(); - this.displayInput.focus(); + this.displayInput.focus({ preventScroll: true }); } // Handle enter and space. When pressing space, we allow for type to select behaviors so if there's anything in the @@ -263,7 +263,7 @@ export default class SlSelect extends ShoelaceElement implements ShoelaceFormCon if (!this.multiple) { this.hide(); - this.displayInput.focus(); + this.displayInput.focus({ preventScroll: true }); } } @@ -368,7 +368,7 @@ export default class SlSelect extends ShoelaceElement implements ShoelaceFormCon } event.preventDefault(); - this.displayInput.focus(); + this.displayInput.focus({ preventScroll: true }); this.open = !this.open; } @@ -382,7 +382,7 @@ export default class SlSelect extends ShoelaceElement implements ShoelaceFormCon if (this.value !== '') { this.setSelectedOptions([]); - this.displayInput.focus(); + this.displayInput.focus({ preventScroll: true }); this.emit('sl-clear'); this.emit('sl-input'); this.emit('sl-change'); @@ -408,7 +408,7 @@ export default class SlSelect extends ShoelaceElement implements ShoelaceFormCon } // Set focus after updating so the value is announced by screen readers - this.updateComplete.then(() => this.displayInput.focus()); + this.updateComplete.then(() => this.displayInput.focus({ preventScroll: true })); if (this.value !== oldValue) { this.emit('sl-input'); @@ -417,7 +417,7 @@ export default class SlSelect extends ShoelaceElement implements ShoelaceFormCon if (!this.multiple) { this.hide(); - this.displayInput.focus(); + this.displayInput.focus({ preventScroll: true }); } } }