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

Fix for: Element/Image drag to move within table is no longer available #3244

Closed
wants to merge 4 commits into from

Conversation

Dumluregn
Copy link
Contributor

@Dumluregn Dumluregn commented Jul 5, 2019

What is the purpose of this pull request?

Bug fix

Does your PR contain necessary tests?

All patches which change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.

This PR contains

  • Unit tests are not reliable as mentioned here
  • Manual tests

What is the proposed changelog entry for this pull request?

[#547](https://github.com/ckeditor/ckeditor-dev/issues/547): Fixed: Element/Image drag to move within table is no longer available when using [Table Selection plugin](https://ckeditor.com/cke4/addon/tableselection).

What changes did you make?

Added drag&drop handling so that table selection no longer needs to cancel those events.

Closes #547.

Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

One issue with dragging text found:

issue1

Also we have discussed approach to unit tests and it seems there is no reasonable way to test the entire d'n'd flow in this case with unit tests - so manuals should be added instead of unit tests.

config.js Outdated Show resolved Hide resolved
this.setData( 'text/html', element.$.outerHTML );
} else {
this.setData( 'text/html', editor.getSelectedHtml( 1 ) );
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is different issue, it also happens on copy/paste. Please see if it is already reported - if not you can report an issue (and maybe link this piece of code as a possible solution). Then we can proceed separately with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reported as #3278. Note that this works fine in FF. It seems to be similar to #972, but that issue is a problem for FF too, so I'm not certain that the cause is the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PR for the fix - #3290, should be merged before this one. I will remove redundant code during rebase onto latest major.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After some digging I think #3278 was just some particular case of #972, so I closed it as duplicate. Still, #3290 should be merged before this as it fixes mentioned clipboard issues (also the one mentioned in another comment).

if ( table && table.hasAttribute( ignoredTableAttribute ) ) {
// (#547)
if ( table && evt.name == 'dragstart' ) {
table.data( ignoredTableAttribute, '' );
Copy link
Contributor

Choose a reason for hiding this comment

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

The element.data() method adds data- prefix so you will end up with data-data-cke-tableselection-ignored. This means this code doesn't add proper ignore attribute and still works which means the attribute may be not needed 🤔

Also the condition for #2945 was removed so you need special attention here to se if nothing gets broken. Btw. I think it will still work with this condition present.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would consider the other way around approach too (not saying it will be better but worth checking) - instead of just always allowing dragging (this is what happens after this change basically), maybe don't prevent dragStart event in more case. The same it is done for table && table.hasAttribute( ignoredTableAttribute ) or !cell || cell.hasClass( fakeSelectedClass ) - it should be also possible to be done for image or text elements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Firstly, you're obviously right - the attribute was misused and useless 👎 But later I found out that trying to reuse it in this case isn't trival, as after drop we want to remove the temporal attribute, and I didn't see a way to distinguish whether it was added by user with #2945 in mind, or just added for dragging, so I decided to restore removed conditions and mimic that solution but with a new, dedicated attribute (I came up with cke-table-dragging-active), except for the part where I control turning it on and off.
As for the second comment, during tests I didn't encounter and can't really think of any edge-case scenario I would like to cut out, so if you have any of them on mind or find it during review please let me know. For now I would like to give a go to this solution.

@Dumluregn
Copy link
Contributor Author

A little summary:
I rebased PR onto latest major. It's ready for review, but will not work properly until #3290 is merged - it fixes the bugs mentioned in this PR like this and this. Without it dragged elements will be pasted nested in additional table.

@Dumluregn Dumluregn marked this pull request as ready for review October 1, 2019 13:00
@Dumluregn Dumluregn requested a review from f1ames October 1, 2019 13:01
@Dumluregn Dumluregn added the pr:frozen ❄ The pull request on which work was suspended due to various reasons. label Mar 26, 2020
@Dumluregn Dumluregn closed this Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:frozen ❄ The pull request on which work was suspended due to various reasons.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Element/Image drag to move within table is no longer available
2 participants