Repository navigation
feat: password icon - #7983
feat: password icon#7983
Conversation
| mask-image: url('@/assets/icon_visible_outlined.svg'); | ||
| } | ||
| &:has(.el-input__inner[readonly]) { | ||
| --el-input-focus-border-color: var(--el-input-border-color); |
There was a problem hiding this comment.
Here are the observations:
Potential issues
-
:has()browser support — already used elsewhere in the file, but note it's not supported in older Firefox (<121) / Safari (<15.4). If the project supports those, the visible/invisible toggle icon will silently fail to switch. -
maskshorthand vsmask-imageoverride — the base rule uses themaskshorthand, then the second rule only overridesmask-image. This works, but it relies on the shorthand having set all longhands (mask-position,mask-size,mask-repeat,mask-mode) first. Since both rules apply to the same element, order matters. It's functional but fragile if anyone later reorders or refactors. Prefer setting individual longhands consistently:&::before { content: ''; width: 1em; height: 1em; background-color: currentColor; mask-position: center; mask-size: contain; mask-repeat: no-repeat; mask-image: url('@/assets/icon_invisible_outlined.svg'); }
Then the toggle rule only changes
mask-image— clean and symmetric. -
display: flex/ centering of the pseudo-element — the::beforeis inline by default with a fixed size; withoutdisplay: inline-blockordisplay: block+ parent flex alignment, you may get baseline misalignment similar to an inline<img>. Consider ensuring vertical centering (e.g.,display: flex; align-items: center; justify-content: center;on&__password, orvertical-align: middleon::before). -
Selector specificity / fragility —
&:has(.el-input__inner[type='text']) &__password::beforecouples deeply to Element Plus internals (el-input__inner,type="text"attribute). Element Plus toggles the input type betweentextandpassword, so this works today, but any EP upgrade that changes the DOM could break it silently. Worth a comment or a regression test. -
Accessibility — hiding the SVG with
display: noneremoves the original icon semantics.::beforewithcontent: ''and a masked background isn't announced to screen readers; make sure the parent still has properaria-label/ title from EP, otherwise the visibility-toggle button becomes unlabeled. -
Asset naming —
icon_invisible_outlined.svgused as the default (password masked = invisible text?) can be confusing. The mapping here (invisible icon whentype="text", i.e., showing plaintext) reads logically, but double-check it matches the intended UX convention. -
Missing
-webkit-mask-*prefixes — for older Safari/Chromium,-webkit-maskmay still be needed depending on your build pipeline. Autoprefixer usually handles this; confirm it's enabled. -
Removed
&__prefixrule — verify nothing else relied on&__prefixstyles (padding, etc.). If other components extendel-inputand expected__prefixstyling, this deletion could regress them.
Optimization suggestions
- Use longhand mask properties consistently (see build(deps): bump the pip group across 1 directory with 1 update #2).
- Add
display: flex; align-items: center;to keep the pseudo-element vertically centered. - Cache-bust / inline small SVGs via
maskwithcurrentColor(already good) — ensure the SVGs are monochrome, otherwisebackground-color: currentColorwon't tint them properly via mask (masks use alpha/luminance, so verify the SVG is filled shapes, not stroke-only, or the mask may be empty). - Consider extracting the duplicated mask URL logic into a mixin for maintainability.
No syntax errors detected; the diff is valid SCSS. The main concerns are cross-browser :has() support, mask-shorthand override ordering, and coupling to Element Plus internals.
feat: password icon