-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Description
Prerequisites
- I have read the Contributing Guidelines.I agree to follow the Code of Conduct.I have searched for existing issues that already report this problem, without success.To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Ionic Framework Version
v8.x
Current Behavior
With the following ion-select:
<ion-select
aria-label="Fruit"
interface="action-sheet"
value="oranges"
placeholder="Select fruit"
[interfaceOptions]="{ header: 'Header' }"
>
<ion-select-option value="apples">Apples</ion-select-option>
<ion-select-option value="oranges">Oranges</ion-select-option>
<ion-select-option value="bananas">Bananas</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
- Click on the select to open it
- See that "Apples" is highlighted instead of "Oranges"
Code Reproduction URL
https://stackblitz.com/edit/f6jtmmrf
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 (cordova-lib@12.0.2)
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
Activity
fix(select): focus the correct selected item
[-]bug: ion-select with header on interface options focus the previous item of the selected on[/-][+]bug: ion-select with action-sheet interface and header focuses the previous item of the selected option[/+]fix(select): focus the correct selected item in an action sheet inter…
ionitron-bot commentedon Jul 31, 2025
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.