Skip to content

[TextField] Fix media hover specificity issue#16266

Merged
oliviertassinari merged 3 commits intomui:masterfrom
arminydy:hotfix/outlinedInput
Jun 18, 2019
Merged

[TextField] Fix media hover specificity issue#16266
oliviertassinari merged 3 commits intomui:masterfrom
arminydy:hotfix/outlinedInput

Conversation

@arminydy
Copy link
Contributor

@arminydy arminydy commented Jun 17, 2019

Closes #16149

Highlight TextField varient outlines border color on focus event on mobile

-Desc: highlight TextField varient outlines border color on focus event on mobile
@mui-pr-bot
Copy link

mui-pr-bot commented Jun 17, 2019

Details of bundle changes.

Comparing: c0e4103...4965b02

bundle parsed diff gzip diff prev parsed current parsed prev gzip current gzip
@material-ui/core +0.01% 🔺 0.00% 318,982 319,010 87,573 87,576
@material-ui/core/Paper 0.00% 0.00% 68,281 68,281 20,353 20,353
@material-ui/core/Paper.esm 0.00% 0.00% 61,578 61,578 19,133 19,133
@material-ui/core/Popper 0.00% 0.00% 28,968 28,968 10,411 10,411
@material-ui/core/Textarea 0.00% 0.00% 5,513 5,513 2,374 2,374
@material-ui/core/TrapFocus 0.00% 0.00% 3,755 3,755 1,580 1,580
@material-ui/core/styles/createMuiTheme 0.00% 0.00% 16,012 16,012 5,791 5,791
@material-ui/core/useMediaQuery 0.00% 0.00% 2,597 2,597 1,102 1,102
@material-ui/lab 0.00% 0.00% 140,580 140,580 43,454 43,454
@material-ui/styles 0.00% 0.00% 51,703 51,703 15,337 15,337
@material-ui/system 0.00% 0.00% 15,303 15,303 4,342 4,342
Button 0.00% 0.00% 84,279 84,279 25,630 25,630
Modal 0.00% 0.00% 20,345 20,345 6,689 6,689
Slider 0.00% 0.00% 74,681 74,681 23,221 23,221
colorManipulator 0.00% 0.00% 3,904 3,904 1,544 1,544
docs.landing 0.00% 0.00% 55,232 55,232 13,946 13,946
docs.main 0.00% 0.00% 651,051 651,051 205,054 205,054
packages/material-ui/build/umd/material-ui.production.min.js +0.01% 🔺 0.00% 292,226 292,254 83,498 83,501

Generated by 🚫 dangerJS against 4965b02

-Desc: highlight TextField varient outlines border color on focus event on mobile
@oliviertassinari oliviertassinari changed the title -ticket: https://github.com/mui-org/material-ui/issues/16149 [TextField] Fix media hover specificity issue Jun 17, 2019
@oliviertassinari oliviertassinari added type: bug It doesn't behave as expected. scope: text field Changes related to the text field. labels Jun 17, 2019
Copy link
Collaborator

@joshwooding joshwooding left a comment

Choose a reason for hiding this comment

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

Tested on mobile, works for me

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 17, 2019

The current approach outputs the following CSS:

.MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline { /* Specificity = 3 */
  border-color: rgba(0, 0, 0, 0.87);
}
.MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline { /* Specificity = 3 */
  border-color: #2196f3;
  border-width: 2px;
}
@media (hover: none) {
  .MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline:hover .MuiOutlinedInput-notchedOutline { /* Specificity = 5 */
    border-color: rgba(0, 0, 0, 0.23);
  }
}

I have updated the pull request to use the patch proposed in the GitHub issue. It outputs the following CSS:

.MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline { /* Specificity = 3 */
  border-color: rgba(0, 0, 0, 0.87);
}
@media (hover: none) {
  .MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline { /* Specificity = 3 */
    border-color: rgba(0, 0, 0, 0.23);
  }
}
.MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline { /* Specificity = 3 */
  border-color: #2196f3;
  border-width: 2px;
}

Notice how the specificity is minimized and the style rule order is correct.

@oliviertassinari
Copy link
Member

@arminydy It's a great first pull request on Material-UI 👌🏻. Thank you for working on it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: text field Changes related to the text field. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Textfield variant outlined's border color doesn't change when focus on mobile

4 participants