This is a follow-up issue from Claro: #3024395: Password Field Style Update
c/ @huzooka @fhaeberle See comment #25

Problem/Motivation

Is not possible to use classes to style separatly the input and it's helper text "Passwords match: (yes/no)" using classes. This is caused because both elements are using password-confirm class.

Proposed resolution

Rework the JS elements of the password field to:
- Create a new JavaScript theme function so that BC layer can be added in Stable
- Replace password-confirm class with password-confirm-message for the text "Passwords match:"

API changes

password-confirm class has been replaced with password-confirm-message for the text "Passwords match:" text. There's a backwards compatibility layer to add password-confirm back in Stable.

Comments

quiron created an issue. See original summary.

quiron’s picture

Title: Password confirm helper text shouldn't use same class than the input » Update JS of password elements to use themes functions and specific class for password confirm message
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new6.9 KB

In this patch:
- Moved helper messages templating from user.js to user.theme.js to use Drupal.theme functions and updated it in user.js
- Changed the class password-confirm to password-confirm-message in the helper text "Passwords match: (yes/no)" to prevent styling with classes conflicts (See: #3024395: Password Field Style Update
- Updated classy/css/components/user.css to use the new password-confirm-message class.

niyas’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new103 KB

This patch seems to work fine.. Suggesting RTBC..

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/user/user.theme.es6.js
@@ -0,0 +1,29 @@
+    `<div aria-live="polite" aria-atomic="true" class="password-confirm-message js-password-confirm-message">${

This seems like a small BC break. This change makes 100% sense but let's override this theme function in Stable with the pre-existing markup to not risk break existing themes.

rosinegrean’s picture

Issue tags: -DevDaysCluj +DevDaysTransylvania
lauriii’s picture

lauriii’s picture

Status: Needs work » Needs review
StatusFileSize
new8.34 KB
new2.21 KB

Implemented BC layer for the markup changes. I also removed changes made to Classy because Classy extends Stable.

lauriii’s picture

I created a change record. I also checked whether this would break Bootstrap theme and I could confirm that they don't have any selectors using password-confirm class.

huzooka’s picture

Re #7, only superficially:

  1. +++ b/core/modules/user/user.es6.js
    @@ -34,30 +34,23 @@
               .addClass('confirm-parent');
    

    Please do not add this CSS class in JavaScript! Neither the .password-parent one a few lines up.

  2. +++ b/core/modules/user/user.es6.js
    @@ -34,30 +34,23 @@
                 .find('div.password-suggestions')
    

    I'd change this qualifying selector to something that is prefixed with 'js-'

lauriii’s picture

@huzooka I don't think those changes are in the scope of what is currently described in the issue summary. I think those are both potentially valid issues. Could you open another issue for trying to tackle them?

lauriii’s picture

Title: Update JS of password elements to use themes functions and specific class for password confirm message » Use specific class for password confirm message
lauriii’s picture

StatusFileSize
new6.36 KB
new3.58 KB

I removed the password meter theme function from the patch since it is unrelated to this issue. We should solve that in a separate issue.

bnjmnm’s picture

The patch looks good - there's just a few clerical things to attend to before I can set to RTBC:

  1. Open followup issue for the issue identified in #9
  2. Update IS to briefly summarize the themes & modules impacted and how this approach supports BC.
  3. There's a typo in the associated CR:
    Password confirm message class name has been changed from password-confirm to password-confirm.
  4. I think The following line in the CR may benefit from a little more clarification (I'm not 100% sure about this as I haven't had to work with change records much)
    This change doesn't affect themes extending Stable or Classy.

    I'm assuming this was added to emphasize there's no breaking changes, but it may be helpful to mention that a new class is still made available to themes that extend Stable or Classy so this isn't interpreted as Stable/Classy not being impacted at all.

lauriii’s picture

Issue summary: View changes
bnjmnm’s picture

Status: Needs review » Reviewed & tested by the community

Paperwork is in good standing, so RTBC.

catch’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/modules/user/user.js
@@ -19,14 +19,13 @@
-          var passwordMeter = '<div class="password-strength"><div class="password-strength__meter"><div class="password-strength__indicator js-password-strength__indicator"></div></div><div aria-live="polite" aria-atomic="true" class="password-strength__title">' + translate.strengthTitle + ' <span class="password-strength__text js-password-strength__text"></span></div></div>';

This line is being removed from user.js but not user.es6.js. Unintentional change?

lauriii’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new5.74 KB
new938 bytes

It seems like there's been some issue with the compilation of the JavaScript. Here's a new patch with recompiled JavaScript.

larowlan’s picture

  • larowlan committed 52a0740 on 8.8.x
    Issue #3061265 by lauriii, quiron, Niyas, bnjmnm, huzooka, catch: Use...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Committed 52a0740 and pushed to 8.8.x. Thanks!

Published change record.

BC layer for stable ✅

Nice work all.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.