Make WordPress Core

Opened 5 months ago

Last modified 8 weeks ago

#64569 new enhancement

Password protected content: password form styling and UX improvements

Reported by: nyiriland's profile Nyiriland Owned by:
Milestone: 7.1 Priority: normal
Severity: normal Version:
Component: Themes Keywords: has-patch
Focuses: ui, accessibility Cc:

Description

This is specifically referring to the form seen when trying to view a password-protected page or post.

The current password protection form currently uses default browser html form styles, though it would be expected to inherit form styling from theme.

Suggestions for improvements:

  • Refactor form to inherit input, label and submit button styles from theme.
  • Improve form accessibility by allowing users to toggle password visibility.

Attachments (3)

form-comment.png (209.2 KB) - added by Nyiriland 4 months ago.
form-password.png (116.7 KB) - added by Nyiriland 4 months ago.
form-suggestion.png (11.2 KB) - added by Nyiriland 4 months ago.

Download all attachments as: .zip

Change History (12)

#1 @joedolson
4 months ago

  • Keywords close added

Core does not provide any CSS styling for the password form. As it is, it will inherit any styles that the theme provides. If the theme does not provide any general styling for form inputs, it could end up with browser styling, but that would be due to gaps in the theme's styling - there's nothing core can do to ensure that theme styles apply to this form.

I'm a bit curious about the suggestion that this form only inherits browser styling and *doesn't* inherit theme styling; that would be very unusual. Do you have an example of this?

When it comes to including a password visibility toggle on this form, I don't think that's really feasible. Trying to create styles that will universally work in any theme isn't really doable; it's up to the theme to implement this.

In my opinion, this ticket should be closed. The first part is invalid, and the second part is just not really feasible.

#2 @Nyiriland
4 months ago

Apologies for not attaching visual documentation previously (was a hurried submission).

I'm a bit curious about the suggestion that this form only inherits browser styling and *doesn't* inherit theme styling; that would be very unusual. Do you have an example of this?

In regards to the form styling, I'm specifically saying the password form doesn't inherit the theme's global styles. Mainly, the submit button:


You can also see that in the markup above, the password input element is nested within the label element, which while technically valid, doesn't match the input/label markup pattern of the default comment form:


At the least, I think changing the markup to inherit the theme's global block button styles could be a welcome improvement:


#3 @joedolson
4 months ago

  • Component changed from General to Themes
  • Keywords needs-patch added; close removed

OK; I think I see what you're requesting now. This is specific to block themes, which don't handle styles the same way as classic themes.

It may be an option to add classes to this form so that block styles can apply, although there are some complicating factors - it's not a block, so variant classes that might get applied elsewhere won't be applied.

The nested label/input pattern is for historic compatibility. This is an old form, and making changes like that can have significant backwards compatibility issues.

But it's worth thinking about for block themes.

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


3 months ago

#5 @sabernhardt
3 months ago

Related issues on the Gutenberg repository:

  1. Add 'wp-element-button' class to the submit input
  2. Create a template for password protected pages
  3. Create a block for the post password form

Adding the .wp-element-button class if wp_is_block_theme() seems to be a simple way to bring theme styles to one element of the form. If the theme.json also includes styles for textInput elements (support added in 6.9), those should apply to the password field.

Last edited 3 months ago by sabernhardt (previous) (diff)

#6 @poena
3 months ago

Adding the .wp-element-button class if wp_is_block_theme() seems to be a simple way to bring theme styles to one element of the form

I created the Gutenberg PR, but in the 7.1 compat folder.
In core, I suppose the change should be made in https://developer.wordpress.org/reference/functions/get_the_password_form/

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


3 months ago

#8 @joedolson
3 months ago

  • Milestone changed from Awaiting Review to 7.1

These changes seem very feasible for 7.1, so I'm going to go ahead and milestone.

This ticket was mentioned in PR #11642 on WordPress/wordpress-develop by @sukhendu2002.


8 weeks ago
#9

  • Keywords has-patch added; needs-patch removed
Note: See TracTickets for help on using tickets.