WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.32k stars 4.12k forks source link

Post: add protected post password field inline error and uncheck "Password protected" for empty field #64157

Open ramonjd opened 1 month ago

ramonjd commented 1 month ago

What problem does this address?

A follow up on:

Context: https://github.com/WordPress/gutenberg/pull/64156#issuecomment-2261912927

1. Add an inline error to warn about a 255+ char password

The protected post field in the database accepts a character count of up to 255.

Anything beyond that returns a server error.

https://github.com/WordPress/gutenberg/issues/64155 limited character input to 255 characters.

Though it is an edge case, it might be useful to indicate to the user that such a password isn't allowed and has been truncated. @peterwilsoncc's idea that one.

2. Uncheck password protected when the password field is empty

When clearing a post password, the Pasword Protected checkbox remains open, even after saving the post.

This communicates that it's enabled, even though the password is empty and the password protection is disabled.

It might be useful to update the showPassword state when toggling the panel to uncheck it.

https://github.com/user-attachments/assets/6cc41c6e-9847-4742-989e-e64a816e5389

Example:

                <Dropdown
                    className="editor-post-status"
                    contentClassName="editor-change-status__content"
                    popoverProps={ popoverProps }
                    focusOnMount
                    renderToggle={ ( { onToggle } ) => {
                        const toggleStatusPanel = () => {
                            onToggle();
                            /*
                             * Reset password visibility
                             * if the password has been cleared.
                             */
                            if ( ! password ) {
                                setShowPassword( false );
                            }
                        };
...

What is your proposed solution?

ramonjd commented 1 month ago

Related: