Skip to content

bug: highlight not showing in ion-item with ion-input #27985

@telpat0298

Description

@telpat0298

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

I've placed an ion-input tag inside an ion-item tag and added the css properties --highlight-color-focused: #0f0 and highlight-height: 2px to the ion-item tag, which per documentation, is correct. The highlight is not shown when the item/input is focused. I tried with mode="md" which makes no difference.

I've tried to investigate the problem myself in in a stackblitz repo and i found that there is a transform: scaleX(0) property on the highlight div-container in the shadow dom of the ion-item element. Therefore the height is always 0px. In the example in the documentation, this scaleX property is overwritten. This doesn't happen in the stackblitz, because in the stackblitz it seems that the has-focus class i never appended to the class list of the item when the item has focus. Only to the child input.

The only two ways i managed to display the highlight are:

  • Place a ion-label inside the item. Then, the highlight is displayed
  • Add legacy="true" to the item

Expected Behavior

The highlight should appear when the css property --highlight-color-focused is present on the ion-item tag.

Steps to Reproduce

  1. Create an ion-item tag
  2. Place an ion-input tag inside
  3. Add the css property --highlight-color-focused to the ion-item tag

Code Reproduction URL

https://stackblitz.com/edit/ionic7-highlight-issue

Ionic Info

Ionic:

Ionic CLI : 7.1.1 (/opt/homebrew/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 7.2.3
@angular-devkit/build-angular : 16.2.0
@angular-devkit/schematics : 16.2.0
@angular/cli : 16.2.0
@ionic/angular-toolkit : 6.1.0

Capacitor:

Capacitor CLI : 4.8.1
@capacitor/android : 4.8.1
@capacitor/core : 4.8.1
@capacitor/ios : 4.8.1

Utility:

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

System:

NodeJS : v18.17.0 (/opt/homebrew/Cellar/node@18/18.17.0/bin/node)
npm : 9.6.7
OS : macOS Unknown

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