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

Selectmenu: Introduce _renderButtonItem method #1299

Closed
wants to merge 2 commits into from

Conversation

fnagel
Copy link
Member

@fnagel fnagel commented Jul 31, 2014

Fixes #10142

menu = element.selectmenu( "menuWidget" );

instance._renderButtonItem = function( buttonItem, item ) {
buttonItem.parent().data( "test", item.value );
Copy link
Member

Choose a reason for hiding this comment

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

Why is this part of the test?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to change the parent node to make sure that possible to. Unnecessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

ps: is this the correct place for test like this?

Copy link
Member

Choose a reason for hiding this comment

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

Very much unnecessary. The extension point is for modifying the item, not the parent. There should be no assumption that you can walk the tree like this. In fact, this makes me change my mind and say that this is not a good implementation. _renderButtonItem() should be generating the item, just like _renderItem() does. That item should then be appended to the button.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, this is the correct file for the test.

Copy link
Member Author

Choose a reason for hiding this comment

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

In fact, this makes me change my mind and say that this is not a good implementation. _renderButtonItem() should be generating the item, just like _renderItem() does. That item should then be appended to the button.

This way we would need to append the element on create and replace the element on each select.

Keep in mind that _renderItems is called once on create or by refresh(). _renderButtonItem is called on create, refresh() and on each item select as we need to update button content.

Copy link
Member

Choose a reason for hiding this comment

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

This way we would need to append the element on create and replace the element on each select.

Why is that an issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably leads to a11y issues as the dom node changes?

Copy link
Member

Choose a reason for hiding this comment

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

Why? There's nothing to indicate that changing the span would be any different than changing the content of the span.

@fnagel
Copy link
Member Author

fnagel commented Aug 2, 2014

I've changed the implementation so the button item element is created within the _renderButtonItem method.

@scottgonzalez
Copy link
Member

looks good

@tjvantoll
Copy link
Member

I put an example together to see that this would look like: http://jsfiddle.net/tj_vantoll/M6899/. I like it; we'll have to make sure we document these methods well though. I'll work on getting the two existing extension points out there.

@jzaefferer
Copy link
Member

For the record, this has to wait for 1.12, so we can't land it right now.

@tjvantoll
Copy link
Member

fyi the PRs for selectmenu's extension points are at jquery/api.jqueryui.com#223 and jquery/api.jqueryui.com#226. When this lands those should land those too.

@scottgonzalez
Copy link
Member

@fnagel Can you update this to handle the new menu item wrappers?

@fnagel
Copy link
Member Author

fnagel commented Oct 30, 2014

@scottgonzalez Sure. It's already in master or is that feature still a PR?

@scottgonzalez
Copy link
Member

It's in master. I was going to merge this just now, but it didn't work because of the wrapper update.

@fnagel fnagel force-pushed the selectmenu-render-button-final branch from a2a3e2f to b8b306d Compare November 3, 2014 23:55
@fnagel
Copy link
Member Author

fnagel commented Nov 3, 2014

Rebased onto master.

};

element.selectmenu( "refresh" );
links = menu.find( "li.ui-menu-item" );
Copy link
Member

Choose a reason for hiding this comment

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

This is never used. I'll remove it when I merge.

Copy link
Member Author

Choose a reason for hiding this comment

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

Uhh, yeah. Seems I missed that when squashing the commits. Thanks!

@fnagel fnagel closed this in fb4124b Nov 4, 2014
fnagel added a commit that referenced this pull request Nov 7, 2014
@fnagel fnagel deleted the selectmenu-render-button-final branch August 25, 2015 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants