Skip to content

Commit 28caeff

Browse files
joselrioIonitronthetaPC
authored
fix(select): remove item focus style when there are no selected items only at ionic mode (#30750)
Issue number: resolves # --------- This PR introduces improvements to the visual focus styling of Ionic items when inside a select modal. ## What is the current behavior? - The CSS variables `--background-focused` and `--background-focused-opacity` were missing from `item.ionic.scss`, which resulted in the native default outline focus style being applied to focused items. - When no item is selected, the focus style is currently applied to the first list item by default, which we intend to change. ## What is the new behavior? - Added missing focus css variables - Hide the default focus style when there is no item selected ## NOTE - This change will require an additional interaction to observe the focus behavior when navigating through keyboard, since tap-based navigation does not rely on focus styling. ## 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. --> --------- Co-authored-by: ionitron <[email protected]> Co-authored-by: Maria Hutt <[email protected]>
1 parent 183a90a commit 28caeff

File tree

6 files changed

+17
-1
lines changed

6 files changed

+17
-1
lines changed

core/src/components/item/item.ionic.scss

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ slot[name="end"]::slotted(*) {
7171

7272
// Item: Focused
7373
// --------------------------------------------------
74-
7574
:host(.ion-focused) .item-native::after {
7675
@include globals.border-radius(inherit);
7776
@include globals.position(0, 0, 0, 0);
@@ -112,3 +111,14 @@ slot[name="end"]::slotted(*) {
112111
:host(.item-lines-none) {
113112
--inner-border-width: #{globals.$ion-border-size-0};
114113
}
114+
115+
// Item in Select Modal
116+
// --------------------------------------------------
117+
:host(.in-select-modal) {
118+
--background-focused: #{globals.$ion-bg-neutral-subtlest-press};
119+
--background-focused-opacity: 0;
120+
}
121+
122+
:host(.in-select-modal.ion-focused) .item-native {
123+
--border-radius: #{globals.$ion-border-radius-400};
124+
}

core/src/components/item/item.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ export class Item implements ComponentInterface, AnchorInterface, ButtonInterfac
407407
'item-control-needs-pointer-cursor': firstInteractiveNeedsPointerCursor,
408408
'item-disabled': disabled,
409409
'in-list': inList,
410+
'in-select-modal': hostContext('ion-select-modal', this.el),
410411
'item-multiple-inputs': this.multipleInputs,
411412
'ion-activatable': canActivate,
412413
'ion-focusable': this.focusable,
-1.02 KB
Loading
1.93 KB
Loading
492 Bytes
Loading

core/src/components/select-modal/select-modal.ionic.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,9 @@ ion-content {
6767
--padding-end: #{globals.$ion-space-400} !important;
6868
/* stylelint-disable-next-line declaration-no-important */
6969
--padding-bottom: #{globals.$ion-space-1200} !important;
70+
71+
// Set the background to the focused element within a radio group only when there is a checked radio
72+
&:has(.radio-checked) .ion-focused:not(.item-radio-checked) {
73+
--background-focused-opacity: 1;
74+
}
7075
}

0 commit comments

Comments
 (0)