Skip to content

bug: ion-select with header on interface options focus the previous item of the selected on #30480

Open
@crazyserver

Description

@crazyserver

Prerequisites

Ionic Framework Version

v8.x

Current Behavior

With the following ion-select:

<ion-select [(ngModel)]="selected" [interfaceOptions]="{header: 'header"> <ion-select-option *ngFor="let entry of entries" [value]="entry.value">{{ entry.label }}</ion-select-option> </ion-select>

When the action sheet is opened, the focused element with "ion-focused" class is the previous of the one that is selected.
On the code it searches the index of the selected item but then it uses nth-child to select it that takes into account the header of the action sheet.

A workaround is to remove the header.

Expected Behavior

The selected element is the one focused.

Steps to Reproduce

See current behaviour.

Code Reproduction URL

https://github.com/moodlehq/moodleapp

Ionic Info

Ionic:

Ionic CLI : 7.2.1 (/Users/pau/.nvm/versions/node/v20.18.1/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 8.5.0
@angular-devkit/build-angular : 17.3.13
@angular-devkit/schematics : 17.3.13
@angular/cli : 17.3.13
@ionic/angular-toolkit : 11.0.1

Cordova:

Cordova CLI : 12.0.0 ([email protected])
Cordova Platforms : android 14.0.0, ios 7.1.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, (and 16 other plugins)

Utility:

cordova-res : not installed globally
native-run : 2.0.1

System:

ios-sim : 8.0.2
NodeJS : v20.18.1 (/Users/pau/.nvm/versions/node/v20.18.1/bin/node)
npm : 10.8.2
OS : macOS Unknown
Xcode : Xcode 16.4 Build version 16F6

But I've tested in ionic 8.6.1 also.

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions