Skip to content

Conversation

@snehapatil2001
Copy link

@snehapatil2001 snehapatil2001 commented Aug 2, 2024

Changes done in PR:

  • Added ARIA attributes (aria-invalid, aria-describedby) to the URL input field.
  • Introduced an error message span below the input field.
  • Implemented spoken error notifications via wp.a11y.speak.
  • Added CSS styling for the error message.
Screen.Recording.2024-08-03.at.3.23.01.AM.mov

Trac ticket: https://core.trac.wordpress.org/ticket/60969


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link

github-actions bot commented Aug 2, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props snehapatil02, joedolson.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

github-actions bot commented Aug 2, 2024

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copy link
Contributor

@joedolson joedolson left a comment

Choose a reason for hiding this comment

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

There are a few improvements that could still be made here.

urlWrap.addClass('has-error');

// Announce error message via screen reader
wp.a11y.speak('Invalid URL. Please enter a valid URL.', 'assertive');
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be a translatable string. Also, the text doesn't match the actual validation rule - which is really only checking whether the value is logically empty. (Either blank, or a protocol with no values.)

The message should probably be something more like "No content entered. Please enter valid link." I don't want to say URL, because you can enter values that aren't URLs - e.g., #content could be used to define a skip link, or #open-modal could be used to open a modal on the page. Because these fields have historically allowed almost any content, we really can't expect a URL now, and the message should reflect that.

// Announce error message via screen reader
wp.a11y.speak('Invalid URL. Please enter a valid URL.', 'assertive');
} else {
urlInput.removeClass('form-invalid')
Copy link
Contributor

Choose a reason for hiding this comment

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

While it makes sense for the error message to fire on submission (since the validation cases pretty much only cover the case where the input field was ignored), the error clearing state should fire on keyup, so the error is cleared as soon as any value that isn't http:// or https:// is entered.

type="text"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?>
class="code menu-item-textbox form-required" placeholder="https://"
/>
<span id="custom-url-error" class="error-message" style="display: none;">Invalid URL.</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

This also needs to be a translatable string; and, similarly, should use text that better reflects the real validation.

Preferably, the error message reported to screen readers should be the same as the one displayed in the input.

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