Skip to content

feat: password icon - #7983

Merged
wangdan-fit2cloud merged 1 commit into
v3from
pr@v3@feat_password_icon
Nov 17, 2026
Merged

wangdan-fit2cloud merged 1 commit into
v3from
pr@v3@feat_password_icon

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

feat: password icon

mask-image: url('@/assets/icon_visible_outlined.svg');
}
&:has(.el-input__inner[readonly]) {
--el-input-focus-border-color: var(--el-input-border-color);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here are the observations:

Potential issues

  1. :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.

  2. mask shorthand vs mask-image override — the base rule uses the mask shorthand, then the second rule only overrides mask-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.

  3. display: flex / centering of the pseudo-element — the ::before is inline by default with a fixed size; without display: inline-block or display: 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, or vertical-align: middle on ::before).

  4. Selector specificity / fragility — &:has(.el-input__inner[type='text']) &__password::before couples deeply to Element Plus internals (el-input__inner, type="text" attribute). Element Plus toggles the input type between text and password, so this works today, but any EP upgrade that changes the DOM could break it silently. Worth a comment or a regression test.

  5. Accessibility — hiding the SVG with display: none removes the original icon semantics. ::before with content: '' and a masked background isn't announced to screen readers; make sure the parent still has proper aria-label / title from EP, otherwise the visibility-toggle button becomes unlabeled.

  6. Asset naming — icon_invisible_outlined.svg used as the default (password masked = invisible text?) can be confusing. The mapping here (invisible icon when type="text", i.e., showing plaintext) reads logically, but double-check it matches the intended UX convention.

  7. Missing -webkit-mask-* prefixes — for older Safari/Chromium, -webkit-mask may still be needed depending on your build pipeline. Autoprefixer usually handles this; confirm it's enabled.

  8. Removed &__prefix rule — verify nothing else relied on &__prefix styles (padding, etc.). If other components extend el-input and expected __prefix styling, 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 mask with currentColor (already good) — ensure the SVGs are monochrome, otherwise background-color: currentColor won'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.

@wangdan-fit2cloud
wangdan-fit2cloud merged commit 1797d7c into v3 Nov 17, 2026
3 of 4 checks passed
@wangdan-fit2cloud
wangdan-fit2cloud deleted the pr@v3@feat_password_icon branch November 17, 2026 11:13
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.

2 participants