Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
telpat0298 opened this issue Aug 14, 2023 · 5 comments
Closed
3 tasks done

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

telpat0298 opened this issue Aug 14, 2023 · 5 comments
Labels

Comments

@telpat0298
Copy link

telpat0298 commented Aug 14, 2023

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

@ionitron-bot ionitron-bot bot added the triage label Aug 14, 2023
@liamdebeasi liamdebeasi self-assigned this Aug 14, 2023
@liamdebeasi
Copy link
Contributor

Thanks for the report. --highlight-color-focused is a deprecated CSS Variable on ion-item that only works with the legacy form syntax. However, I realize this is confusing since there is no deprecation warning. I opened #27987 to address this.

Your example without ion-label is using the modern form syntax which does not render a highlight. This is intentional and aligns with the Material Design spec. Inputs in a list typically do not show the focus highlight. However, if you were to use the input outside of a list then you could use the --highlight-* CSS properties on ion-input.

The other two examples appear to work because they are using the legacy form syntax by adding an ion-label to the item. You can verify this by looking at the deprecation warnings in the console.


I am going to close this as Ionic is working as intended, though I will be sure that a deprecated note gets added to our docs. Let me know if you have any questions.

@liamdebeasi liamdebeasi closed this as not planned Won't fix, can't repro, duplicate, stale Aug 14, 2023
@liamdebeasi liamdebeasi removed their assignment Aug 14, 2023
@telpat0298
Copy link
Author

telpat0298 commented Aug 14, 2023

@liamdebeasi Thanks for the answer. In the provided documentation link (this one) not only the deprecated warning is missing, it is not working as described. Setting these variables (--highlight-height, --highlight-color-invalid, ...) has no effect or what so ever on the highlight. Also, setting these variables directly on the input inside an item has no effect. Is there any other way to signal e.g. an invalid input with highlights or is this now up to the developer?

Thanks

@liamdebeasi
Copy link
Contributor

That documentation is for the legacy syntax which is why the styles are only set on the ion-item. That demo should probably be removed.

@telpat0298
Copy link
Author

Ok, thanks for helping

github-merge-queue bot pushed a commit that referenced this issue Aug 14, 2023
Issue number: N/A

---------

<!-- 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 was some confusion on
#27985 as to how the
`--highlight-*` variables on `ion-item` apply to the modern form
controls. These variables only work with the legacy form syntax, but we
did not add a proper deprecation message.

`--highlight-*` variables have been added to `ion-input` and
`ion-textarea` instead so developers can customize the highlight when
using the modern form syntax.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Deprecated the `--highlight-*` variables on `ion-item`.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->
@ionitron-bot
Copy link

ionitron-bot bot commented Sep 13, 2023

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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants