mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-15 05:59:05 +08:00
fix(select): focus the correct selected item in an action sheet interface with a header (#30481)
Issue number: resolves #30480 --------- ## What is the current behavior? When using a select component with the `action-sheet` interface, a `header`, and a default selected value, the action sheet opens with the wrong item focused. This happens because the focus logic uses `nth-child` to target the selected item, which incorrectly includes the header since it is a child element. As a result, the focus is shifted one item above the correct selection. ## What is the new behavior? - Correctly focus the selected item when opening an `action-sheet` with a header from a select. - Adds e2e tests for verifying this behavior. ## Does this introduce a breaking change? - [ ] Yes - [X] No ## Other information [Preview](https://ionic-framework-git-fork-crazyserver-patch-2-ionic1.vercel.app/src/components/select/test/basic) --------- Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>
This commit is contained in:
@@ -349,7 +349,7 @@ export class Select implements ComponentInterface {
|
||||
const indexOfSelected = this.childOpts.findIndex((o) => o.value === this.value);
|
||||
if (indexOfSelected > -1) {
|
||||
const selectedItem = overlay.querySelector<HTMLElement>(
|
||||
`.select-interface-option:nth-child(${indexOfSelected + 1})`
|
||||
`.select-interface-option:nth-of-type(${indexOfSelected + 1})`
|
||||
);
|
||||
|
||||
if (selectedItem) {
|
||||
|
||||
Reference in New Issue
Block a user