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: Image in table cell has an empty URL field when edited from context menu opened by right-click #3059

Merged
merged 23 commits into from
Jun 14, 2019

Conversation

Dumluregn
Copy link
Contributor

@Dumluregn Dumluregn commented Apr 16, 2019

What is the purpose of this pull request?

Bug

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

As this was a specific issue and required opening context menu by right-click (keyboard shortcuts were working fine before fix) there is just a short 15 seconds manual test included.

  • Unit tests
  • Manual tests

What changes did you make?

I made Table Selection treat images from Image plugin the same way it operates on widgets, etc from Enhanced Image plugin (i.e. an early return in function checking if the table is selected).

Closes #2235.

@f1ames
Copy link
Contributor

f1ames commented May 9, 2019

Rebased on the latest master.

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.

This one is a little tricky. The part detecting if image is selected is fine however I'm wondering on the placement of this code.

First of all, the isTableSelection() function is further used in selection.isInTable() method (apart from few other places in selection.js). This means that with this change, we change the selection logic - if image inside table is selected, selection.isInTable() returns false indicating that selection is not inside the table. I'm not sure if this is the right assumption 🤔
This affects all places and plugins using this method (not that much apart from tableselection and tabletools plugin).

I have also found one case where fake selection is not correctly reseted:

ts issue 1

It happens after pressing Delete/Backspace over tableselection. Then the image cannot be selected and cursor is different (because the fake selection is still active). Only after reselecting some cells and then clicking somewhere in the table fake selection is properly reseted. This worked fine before this change.

My suggestion is to try to find the cause of the above issue and move proposed code from the selection.js to tableselection/plugin.js - fakeSelectionChangeHandler() function seems to be a good place to check (it uses selection.isInTable() method). I briefly checked and it worked (however, the issue mentioned above was still visible so it might require some additional changes).

core/selection.js Outdated Show resolved Hide resolved
core/selection.js Outdated Show resolved Hide resolved
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.

Have you checked if unit tests could be created to test this fix? I see there are some tests in tableselection plugin simulating right click (https://github.com/ckeditor/ckeditor-dev/blob/major/tests/plugins/tableselection/rightclick.js). Maybe this fix can be tested in a similar fashion?

core/selection.js Show resolved Hide resolved
@Dumluregn
Copy link
Contributor Author

About unit test - it was impossible to exactly mimic the scenario (using context menu or dialog didn't work), so instead test is checking if after selecting image the cell becomes fake-selected or not. That was the reason of incorrect behaviour before, so as long as the test passes this patch should work fine.

@Dumluregn Dumluregn requested a review from f1ames May 23, 2019 11:57
@Dumluregn Dumluregn changed the base branch from master to major May 23, 2019 11:58
@f1ames f1ames self-assigned this May 23, 2019
@f1ames
Copy link
Contributor

f1ames commented May 23, 2019

Rebased on the latest major.

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.

Looks good 👍

However, it doesn't work on Edge and IE11:

image table edge

image table ie11

TBH, it looks like a different issue, not related to this one. Can you confirm if it happens also without tableselection plugin? If so, could you extract it to a separate ticket and then we can merge this one. However, if it happens only with tableselection it needs to be covered in this PR as a part of this bugfix.

@Dumluregn
Copy link
Contributor Author

Dumluregn commented May 27, 2019

@f1ames - thanks for bringing my attention to IE11+ and Edge. The issue was occuring because those browsers has been marking selection as fake even when selection didn't exceed the original cell. I added an additional selection reset and now everything should work fine.

@Dumluregn Dumluregn requested a review from f1ames May 27, 2019 10:27
@f1ames
Copy link
Contributor

f1ames commented May 27, 2019

@Dumluregn please take a look at CI, there is quite significant number of unit tests failing for editor build version (both Chrome and Firefox).

On the dev version only few tests are run with tableselection plugin (ones where it is explicitly added). On the build one, where full-all build is used, all default plugins (which means tableselection too) are present in most of the tests. And it seems that after recent changes, tableselection doesn't play well with the rest of the editor 😅

@Dumluregn
Copy link
Contributor Author

Dumluregn commented May 28, 2019

Yeah, it seems I limited fake selection a little bit too much. Now CI is green again.

@f1ames f1ames self-assigned this Jun 13, 2019
@f1ames
Copy link
Contributor

f1ames commented Jun 13, 2019

Rebased on the latest major.

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.

LGTM, good job 👍

I found 2 not related issues in IE11 which I will extract to a separate tickets.

@f1ames f1ames merged commit fe24402 into major Jun 14, 2019
@CKEditorBot CKEditorBot deleted the t/2235 branch June 14, 2019 11:52
@f1ames
Copy link
Contributor

f1ames commented Jun 14, 2019

Extracted two issues #3166 and #3167.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image in table cell has an empty URL field when edited from context menu opened by right-click
2 participants