-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Selectmenu: Introduce _renderButton method #1297
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
Conversation
Fixes #10142
Let's add a test for this. Otherwise looks good. |
Ok, but what should I test here? |
"aria-expanded": "false", | ||
"aria-autocomplete": "list", | ||
"aria-owns": this.ids.menu, | ||
"aria-haspopup": "true" |
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.
None of this can be in here. These are all required functionality.
This needs to wait until 1.12.0 since it's adding a new API. |
This implementation is actually quite wrong. The extension point is supposed to be an equivalent of |
Looks good vs. five comments ;-) @scottgonzalez Ok, but how should it look like? Just return an plain jQuerified span? Adding to dom and adding required attributes later on? |
Or is this already the answer to my question? So just extract the adding to dom from the current version? |
Essentially, you should've replaced |
I'm going to close this for now since it doesn't actually address the request in the ticket. |
The actual request in the ticket (changing color) can already be done by using callback events as I outlined in my fiddle in the ticket. I think the outlined way to go is the best way to do so. In my opinion the ticket talks about two things:
We don't want to re-render / replace the button markup on each item select as that would break a11y handling. And we have multiple attributes required for a11y which is tricky when we allow to customize the markup of the button. Proposal: Add a _renderButton method which returns a span already including all attributes. Within this method we create the buttonText span and the icon span, too. Only appending to the DOM is done in _drawButton. In addition we add a method (like _changeButton) which by default just calls _setText on the buttonText span. |
I have no idea where you're getting this from. The request is just about the rendering of the item itself. |
The item itself (the button) is only rendered once on create. The given use case (changing color) is not achievable by just modifying the rendering on create.
This is where I get this from. The 'original' selectmenu copied the classes and the content of the selected option to the button element. It's a misunderstanding of how selectmenu widget works. Anyway: adding a _renderButton or better _changeButton method as I outlined above seems helpful for the color change use case and especially when considering the use case of http://bugs.jqueryui.com/ticket/10189 |
The item is not the button. The button contains the item.
That can be accomplished without touching the actual button, just it's content. |
Ok, perhaps we can talk better about what we have in mind by taking a look this implementation: fnagel@bf0b549 I think it's very flexible but provides us a little more safety regarding needed attributes / a11y settings. |
I have no desire to expose a method for rendering the actual button when it requires setting and appending an internal property. Similarly, |
And another try: fnagel@a65a6d6 If we want to pass the item object to the _renderButtonItem method it's needed to parse the option. We could easily change this to use the option itself (and have a quite smaller changeset) but using the item object seems more consistent to me. |
Sorry, posted wrong link. Updated comment. |
That looks good. Can you add a test that overrides the method on a widget instance? |
Yes. I will open a new pull request. |
Replaced with #1299 |
Fixes #10142
Add extension point for modifying the button element (aka the selected item).