Skip to content

Commit cad1c61

Browse files
thetaPCbrandyscarney
andauthoredApr 16, 2025
fix(select): update icon color and use correct focused class (#30342)
Issue number: internal --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> There are a few items to note: - Styles are using a non-existing focus class. It currently uses `.has-focus` which isn't being used anywhere within `select.tsx`. It seems that `.has-focus` comes a copy and paste that wasn't updated. - Icon uses the highlight color when expanded, in item, and no fill. This leads to the styling looking weird compared to when it's not in an item especially since labels do not change colors. Only applies to `md` mode. | List no lines | List with lines | | --- | ----------- | | ![Screenshot 2025-04-07 at 1 01 14 PM](https://github.com/user-attachments/assets/e310e5e8-d0bc-4976-b623-c8db358307c8) | ![Screenshot 2025-04-07 at 1 01 31 PM](https://github.com/user-attachments/assets/d4c0776d-cd5d-48a1-95a3-42b74e3dd767) | - The focus without a validation status does not update the border correctly when inside an item and has a solid fill. Only applies to `md` mode. | Outside item | Inside item | |--------|--------| | ![Screenshot 2025-04-07 at 1 07 13 PM](https://github.com/user-attachments/assets/ee8c4fff-630d-4f7c-b3c5-f9daf22ff7d4) | ![Screenshot 2025-04-07 at 1 08 45 PM](https://github.com/user-attachments/assets/046d69fc-823e-4fa4-a19f-f8e641874b4d) | ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Styles are now using the correct focus class: `.has-focus`, removing `ion-focused`. - If the select is inside an item and has no fill then the icon will not use the highlight color. Only applies to `md` mode. | List no lines | List with lines | | --- | ----------- | | ![Screenshot 2025-04-07 at 1 13 17 PM](https://github.com/user-attachments/assets/0e6fd28e-4925-4799-a24b-8e21348eb168) | ![Screenshot 2025-04-07 at 1 14 11 PM](https://github.com/user-attachments/assets/adec2576-27d9-4150-8e60-8af5fa9cc012) | - The focus without a validation status uses the highlight color when inside an item and has a solid fill. Only applies to `md` mode. | Outside item | Inside item | |--------|--------| | ![Screenshot 2025-04-07 at 1 07 13 PM](https://github.com/user-attachments/assets/ee8c4fff-630d-4f7c-b3c5-f9daf22ff7d4) | ![Screenshot 2025-04-07 at 1 16 47 PM](https://github.com/user-attachments/assets/bc8b03b9-6ad1-40b0-a7fd-3f6e654ec066) | ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> Dev build: `8.5.4-dev.11744743162.1ec9251d` Select cannot have a focused class and an expanded class at the same time. It's one or the other. --------- Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com>
1 parent d52fca0 commit cad1c61

File tree

57 files changed

+453
-117
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+453
-117
lines changed
 

‎core/src/components/input/input.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,20 @@ export class Input implements ComponentInterface {
5050
* Resets when the input loses focus.
5151
*/
5252
private didInputClearOnEdit = false;
53+
5354
/**
5455
* The value of the input when the input is focused.
5556
*/
5657
private focusedValue?: string | number | null;
5758

59+
/**
60+
* The `hasFocus` state ensures the focus class is
61+
* added regardless of how the element is focused.
62+
* The `ion-focused` class only applies when focused
63+
* via tabbing, not by clicking.
64+
* The `has-focus` logic was added to ensure the class
65+
* is applied in both cases.
66+
*/
5867
@State() hasFocus = false;
5968

6069
@Element() el!: HTMLIonInputElement;

‎core/src/components/select/select.md.outline.scss

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
* the select is focused.
4444
*/
4545
:host(.select-fill-outline.select-expanded),
46-
:host(.select-fill-outline.ion-focused) {
46+
:host(.select-fill-outline.has-focus) {
4747
--border-width: var(--highlight-height);
4848
--border-color: var(--highlight-color);
4949
}
@@ -240,3 +240,18 @@
240240
:host(.label-floating.select-fill-outline) .select-outline-notch {
241241
border-top: none;
242242
}
243+
244+
// Select Icon
245+
// ----------------------------------------------------------------
246+
247+
/**
248+
* When the select has an outline fill and
249+
* in an item, then the icon should
250+
* take on the highlight color.
251+
*/
252+
:host(.in-item.select-expanded.select-fill-outline) .select-wrapper .select-icon,
253+
:host(.in-item.has-focus.select-fill-outline) .select-wrapper .select-icon,
254+
:host(.in-item.has-focus.ion-valid.select-fill-outline) .select-wrapper .select-icon,
255+
:host(.in-item.ion-touched.ion-invalid.select-fill-outline) .select-wrapper .select-icon {
256+
color: var(--highlight-color);
257+
}

0 commit comments

Comments
 (0)