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

Sortable: Append a tr with td to the placeholder of tbody elements #1380

Closed
wants to merge 5 commits into from

Conversation

oemmes
Copy link
Contributor

@oemmes oemmes commented Oct 31, 2014

When sorting tbody elements of a table the placeholder needs to have a tr with
td elements to be visible. The appended elements are created in the same way
as for the placeholder of a tr element; the first row of the sorted tbody is
used for that.

When sorting tbody elements of a table the placeholder needs to have a tr with
td elements to be visible. The appended elements are created in the same way
as for the placeholder of a tr element; the first row of the sorted tbody is
used for that.
@scottgonzalez
Copy link
Member

Thanks for the patch. Please make sure to contribution guidelines which outline how to properly contribute a fix. You're missing the following:

  • File a ticket describing the issue.
  • Sign the CLA.
  • Conform to the style guide.
  • Write tests.

I'm going to close this for now, but feel free to push updates and notify us and we'll reopen. If you have any questions, just ask here. Thanks.

@oemmes
Copy link
Contributor Author

oemmes commented Nov 3, 2014

Hi,

I updated my forked branch to match the style guide and added a test for tbody placeholders.

I also signed the CLA and created a ticket:
http://bugs.jqueryui.com/ticket/10682

Please check if my PR is correct now and may be merged into master.

@tjvantoll
Copy link
Member

This does seem to address the problem: http://jsfiddle.net/tj_vantoll/zL8uj2em/

Would it make sense to also include <thead> elements, as I'm guessing they're subject to the same problem?

For this PR there are still some style violations, which you can find by running grunt. We'll also want a unit test that validates that this functionality works.

@tjvantoll tjvantoll reopened this Nov 3, 2014
@oemmes
Copy link
Contributor Author

oemmes commented Nov 3, 2014

The HTML specifications do only allow one <thead> per <table> and it has to precede <tbody> elements. So I think sorting <thead> doesn't make much sense at all.

As for the style validations and the unit test: these were the 2 new commits to this PR. I think they were not appended while the ticket was closed. If I missed something else, please point it out :)

@oemmes
Copy link
Contributor Author

oemmes commented Dec 11, 2014

@tjvantoll: may I ask for a short feedback?
Can my pull request be merged eventually? Or is there still something missing?

@tjvantoll
Copy link
Member

Sorry for the late response @oemmes. I have this on my list of things to do before the 1.12 release, which is still a little ways off. I don't see anything glaringly wrong, but I don't have time look at this in depth at the moment.

@scottgonzalez
Copy link
Member

@tjvantoll Were you still planning on reviewing this?

@@ -830,6 +831,16 @@ return $.widget("ui.sortable", $.ui.mouse, {

},

_createTrPlaceholder: function(that, sourceTr, targetTr) {
that = that || this;
Copy link
Member

Choose a reason for hiding this comment

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

The first parameter is unnecessary. You can change this line to var that = this;.

@oemmes
Copy link
Contributor Author

oemmes commented Feb 5, 2015

@tjvantoll: Thanks for the feedback.
I made some changes to the code according to your suggestions.

A little explanation for the <tr> element that is created:
The actual placeholder element is already a <tbody> which is added to the sortable. But it is not visible unless it contains any cells. That's the reason for adding the <tr> to it.

@tjvantoll
Copy link
Member

Ok that makes sense, and thanks for sticking with this. @scottgonzalez this looks good to me.

.appendTo( element );
});
if ( nodeName === "tbody" ) {
that._createTrPlaceholder( that.currentItem.find( "tr:first" ), $( "<tr></tr>", that.document[0] ).appendTo( element ) );
Copy link
Member

Choose a reason for hiding this comment

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

  • Avoid use of :first selector, use a filter method like .eq( 0 ).
  • Empty element construction uses just the opening name: $( "" )
  • Missing spaces inside brackets.
  • This line exceeds 100 characters.

@oemmes
Copy link
Contributor Author

oemmes commented Feb 24, 2015

@scottgonzalez I adjusted the code again. Hopefully it fits the guidelines now.

@scottgonzalez
Copy link
Member

Thanks, squashed and landed in master.

@oemmes oemmes deleted the tbody_placeholder branch February 26, 2015 10:51
scottgonzalez pushed a commit that referenced this pull request Mar 10, 2015
When sorting tbody elements of a table the placeholder needs to have a tr with
td elements to be visible. The appended elements are created in the same way
as for the placeholder of a tr element; the first row of the sorted tbody is
used for that.

Fixes #10682
Closes gh-1380
(cherry picked from commit 962e05d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants