Skip to content

Labels for input fields are rendered inconsistently #7701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
robincornett opened this issue Apr 2, 2020 · 3 comments · May be fixed by #8023
Open

Labels for input fields are rendered inconsistently #7701

robincornett opened this issue Apr 2, 2020 · 3 comments · May be fixed by #8023

Comments

@robincornett
Copy link
Contributor

Bug Report

Expected behavior

When I add a label to an input, it should be properly associated with the input (eg: clicking on the label should move focus to the input).

Actual behavior

  • When I add a label to a text field in a repeater row, the use of edd_sanitize_key in the text method strips out the [] and the label is disconnected from the field.
  • The textarea method uses $args['name'] for the label; text uses $args['id']
  • 3.0 adds a label to the checkbox, but it more properly uses esc_attr so that it works in repeaters
  • some uses of the html-> methods define an id, but quite a few do not, and just use name
  • if an id is not defined for a text field, for example, the text field will end up with no id

Steps to reproduce the behavior

  1. Edit a download and enable variable pricing
  2. Inspect the input fields in the Price ID row.

For the Option Name field:

  • There is no label associated with the input field
  • The span id is edd-edd_variable_prices1name-wrap because of the use of edd_sanitize_key
  • To add a label, two parameters must be added to the field defintion: both a label and an id, or else the for will be blank and the label will not be associated with the field

Price and Default have similar issues.

Information (if a specific version is affected):

PHP Version: 7.3.5
EDD Version (or branch): master, 3.0
WordPress Version: 5.4

Any other relevant information:
As I'm working with the SL licensing addon, I'm seeing inconsistencies with how labels are added to fields--visually, most fields have some kind of visual label, but in repeatable rows especially, they're not present, which makes the inputs less accessible. This looks to be something that needs to be worked on both in Core and in extensions which use the EDD->html functions.

robincornett added a commit that referenced this issue Apr 14, 2020
Using edd_sanitize_key was breaking HTML elements which included
[] characters.

#7701
@robincornett robincornett linked a pull request Jun 19, 2020 that will close this issue
@robincornett robincornett linked a pull request Jun 19, 2020 that will close this issue
@LisaCee
Copy link
Contributor

LisaCee commented Oct 19, 2020

Can I add a tweak to a class method in this issue, too? Can the span ID in the EDD()->html->date_field class method be changed to use a class instead (or alternatively, to create unique ids) as suggested here in this issue?

@robincornett
Copy link
Contributor Author

@LisaCee I went ahead and changed that to a class, and brought this up to date with release/3.0. I think anything we do with this class needs to be checked with lots of extensions, as it likely touches each and every one of them (part of the reason it's still a draft).

@ashleyfae
Copy link
Contributor

I think the main concern is if those IDs are used in JavaScript anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants