Skip to content
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

fix(floating-label): override inline transform during autofill #2079

Merged
merged 2 commits into from
Jun 6, 2023

Conversation

LuLaValva
Copy link
Member

@LuLaValva LuLaValva commented Jun 5, 2023

  • This PR contains CSS changes
  • This PR does not contain CSS changes

Description

There are some edge cases that we can't currently handle without a major JavaScript refactor regarding floating labels, which are simple to fix with modern CSS. In this PR I provide a few selectors which will fix these issues on modern browsers, and preserve current behavior if the :has selector is not supported.

I tested this using npm link from ebayui-core's floating-label-autocomplete branch. It may be worth it to add this as a test, but for now I think it is ok just to have up for testing purposes.

Notes

  • I had originally planned to use the @supports group to handle browsers which did not support :has, but our less bundler is outdated and it will not compile properly. Related to this issue, which was fixed in version 10.2.5 of autoprefixer, but less-plugin-autoprefix uses an older version and also breaks when I force it to use the newest.
    • I think I actually prefer the way I did it, since it is not absolutely necessary to bring in @supports.
  • The transform rules here are duplicated from above which I am not a fan of, but stylelint won't let me group them together because of the no-descending-specificity rule.

Screenshots

Before:

image

After:

image

Checklist

  • I verify the build is in a non-broken state
  • I verify all changes are within scope of the linked issue
  • I regenerated all CSS files under dist folder
  • I tested the UI in all supported browsers
  • I did a visual regression check of the components impacted by doing a Percy build and approved the build
  • I tested the UI in dark mode and RTL mode
  • I added/updated/removed Storybook coverage as appropriate

@LuLaValva LuLaValva requested review from ArtBlue and ianmcburnie June 5, 2023 23:39
ianmcburnie
ianmcburnie previously approved these changes Jun 6, 2023
Copy link
Contributor

@ArtBlue ArtBlue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the fact that :has doesn't have full support and the fix will not work on many browsers, the selectors look to need tweaking.

If we do use this solution, we should have an autofill example in Skin docs and storybook.

I realize this is somewhat of a user-specific thing that gets triggered on page usage, but it will help to confirm fixes and see breaks in the future by using a fairly common autocomplete="username" attribute.


// Autofill

label.floating-label__label:has(+ .textbox :autofill) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The transform is getting overwritten. The selector seems to need more specificity...
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...or possibly, that transform is from a different selector and the :has isn't getting applied at all?

transform: scale(0.75, 0.75) translate(0, 2px);
}

.floating-label--large label.floating-label__label:has(+ .textbox :autofill) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This selector seems to need more specificity as it's getting overwritten.
image

@ArtBlue
Copy link
Contributor

ArtBlue commented Jun 6, 2023

Where are the before and after screenshots from?

@LuLaValva
Copy link
Member Author

Thanks for the comments @ArtBlue, we talked offline and resolved all of the issues. As it turns out, for sufficiently large websites such as the skin site Chrome stops supporting sufficiently general selectors, so I made them more specific.

Copy link
Contributor

@ArtBlue ArtBlue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@LuLaValva LuLaValva self-assigned this Jun 6, 2023
@LuLaValva LuLaValva linked an issue Jun 6, 2023 that may be closed by this pull request
@LuLaValva LuLaValva changed the base branch from master to 16.2.2 June 6, 2023 17:13
@LuLaValva LuLaValva merged commit 9b51ea4 into 16.2.2 Jun 6, 2023
@LuLaValva LuLaValva deleted the floating-label-autocomplete branch June 6, 2023 17:15
LuLaValva added a commit that referenced this pull request Jun 6, 2023
fix(floating-label): override inline transform during autofill (#2079)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Floating Label has a few edge cases with Chrome's autocomplete
3 participants