Skip to content
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

Checkbox labels accessibility #4

Merged
merged 1 commit into from Mar 28, 2019

Conversation

Projects
None yet
2 participants
@audrasjb
Copy link

audrasjb commented Mar 28, 2019

Hi,

Label should match the id attribute of the checkbox, not their name.

I replaced

		<label for="<?php esc_attr_e( $args['id'] ); ?>">
			<input type="checkbox" name="wp-beta-tester[<?php esc_attr_e( $args['id'] ); ?>]" value="1" <?php checked( '1', $checked ); ?> >
			<?php esc_attr_e( $args['title'] ); ?>
		</label>

with

		<label for="<?php esc_attr_e( $args['id'] ); ?>">
			<input type="checkbox" id="<?php esc_attr_e( $args['id'] ); ?>" name="wp-beta-tester[<?php esc_attr_e( $args['id'] ); ?>]" value="1" <?php checked( '1', $checked ); ?> >
			<?php esc_attr_e( $args['title'] ); ?>
		</label>

Cheers,
Jb

@afragen afragen merged commit bf9b32c into afragen:master Mar 28, 2019

@afragen

This comment has been minimized.

Copy link
Owner

afragen commented Mar 28, 2019

Can I get this to the develop branch.

@afragen

This comment has been minimized.

Copy link
Owner

afragen commented Mar 28, 2019

Nevermind. I was able to pull the PR into the develop branch and push it out for release.

Thanks.

@afragen

This comment has been minimized.

Copy link
Owner

afragen commented Mar 28, 2019

@audrasjb out of curiosity would the a11y issue be fixed if the code was changed to the following.

<label for="wp-beta-tester[<?php esc_attr_e( $args['id'] ); ?>]">
	<input type="checkbox" name="wp-beta-tester[<?php esc_attr_e( $args['id'] ); ?>]" value="1" <?php checked( '1', $checked ); ?> >
	<?php esc_attr_e( $args['title'] ); ?>
</label>
@afragen

This comment has been minimized.

Copy link
Owner

afragen commented Mar 28, 2019

Answered in Slack. Short answer, it’s not the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.