-
Notifications
You must be signed in to change notification settings - Fork 28
feat: add support for required attribute #53
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
base: trunk
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for making this change and making this lib more accessible. I've left some comments
|
||
this.container = container; | ||
|
||
if (isRequired) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a PR under review that drops select2
So these changes might not be required.
|
||
this.container = container; | ||
|
||
if (isRequired) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for this file ^
@@ -4420,7 +4429,7 @@ S2.define('select2/dropdown/attachBody',[ | |||
|
|||
if (newDirection == 'above' || | |||
(isCurrentlyAbove && newDirection !== 'below')) { | |||
css.top = container.top - parentOffset.top - dropdown.height; | |||
css.top = container.top - dropdown.height; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious, why we had to make this change? and that too only for Select2 lib and not SelectWoo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been auto-compiled and bundled within here because of changes from a previous PR that didn't get compiled: https://github.com/woocommerce/selectWoo/pull/49/files
<select name="required_option" id="required_option" class="country_to_state country_select "><option value="">Select a country… (required)</option><option value="AX" >Åland Islands</option><option value="AF" >Afghanistan</option><option value="AL" >Albania</option><option value="DZ" >Algeria</option><option value="AS" >American Samoa</option><option value="AD" >Andorra</option><option value="AO" >Angola</option><option value="AI" >Anguilla</option><option value="AQ" >Antarctica</option><option value="EH" >Western Sahara</option><option value="YE" >Yemen</option><option value="ZM" >Zambia</option><option value="ZW" >Zimbabwe</option></select> | ||
|
||
<script> | ||
$( '#not_required' ).select2(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we also should use .selectWoo
signature which is consistent with what we are using in the core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every other HTML file in the sample
directory uses select2
, so I thought I'd be consistent here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though we still support select2's signature, we have officially removed it from our repo, woocommerce/woocommerce#48731. Maybe as part of another Issue, we should keep the samples consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that sounds fine!
This pull request includes a
Adding support for the
required
attribute, so that it can be read by Screen Readers.Porting of the changes from woocommerce/woocommerce#48371
I added examples in the
docs/accessibility-testing/
directory for how to instantiate a "required" select.The following changes were made
aria-required
to thecombobox
andtextbox
elements, for better support w/ Firefox, Chrome, etc.required
attribute can be set via option on instantiation, or viarequired
attribute on the originalselect
elementI noticed that the assets are committed compiled in the repo - so I built them as well.