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

[Style dropdown] Block style applied to the block before a block widget #11585

Closed
Tracked by #11574
niegowski opened this issue Apr 7, 2022 · 6 comments Β· Fixed by #13822
Closed
Tracked by #11574

[Style dropdown] Block style applied to the block before a block widget #11585

niegowski opened this issue Apr 7, 2022 · 6 comments Β· Fixed by #13822
Assignees
Labels
package:style squad:core Issue to be handled by the Core team. type:bug This issue reports a buggy (incorrect) behavior.

Comments

@niegowski
Copy link
Contributor

πŸ“ Provide detailed reproduction steps (if any)

2022-04-07 11 15 16

βœ”οΈ Expected result

Only blocks that are visually selected should be affected.

❌ Actual result

A block before a block widget gets the style.

❓ Possible solution

πŸ“ƒ Other details

  • Browser: …
  • OS: …
  • First affected CKEditor version: …
  • Installed CKEditor plugins: …

If you'd like to see this fixed sooner, add a πŸ‘ reaction to this post.

@niegowski niegowski added type:bug This issue reports a buggy (incorrect) behavior. squad:core Issue to be handled by the Core team. package:style labels Apr 7, 2022
@CKEditorBot CKEditorBot added the status:planned Set automatically when an issue lands in the "Sprint backlog" column. We will be working on it soon. label Mar 29, 2023
@filipsobol filipsobol self-assigned this Mar 31, 2023
@CKEditorBot CKEditorBot added status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. and removed status:planned Set automatically when an issue lands in the "Sprint backlog" column. We will be working on it soon. labels Mar 31, 2023
@filipsobol
Copy link
Member

This seems to be consistent with the behavior of other block operations.

If we select the last paragraph, the image, and the end of the heading, as in the GIF above, the style, quote, and code block operations will affect the heading block.
However, if we select only the last paragraph and image, the style and code block operations are disabled, and the quote operation will not affect the heading block.

See this video where I first select only the last paragraph and image, and then also the end of the heading.

recording.mp4

@Witoso
Copy link
Member

Witoso commented Apr 3, 2023

Good find @filipsobol! I just want to share another recording that may better show where the problem is, and why it may be confusing for the user:

Screen.Recording.2023-04-03.at.09.12.12.mov

Notice that as a user I only slightly raise my selection above the paragraph. My expectation is I select part of the paragraph, and the image. But this small selection (user's perspective), selects heading as well. It's even more visible if you have an empty paragraph. Users may have the intuition, "I only select what's on the level of my cursor", and unfortunately we break this pattern here.

Not sure where the problem lies but it's still there.

@filipsobol
Copy link
Member

@filipsobol
Copy link
Member

We decided to ignore the first selected block if the selection starts at the end of that block:

<paragraph>a[</paragraph> // This block should be ignored
<paragraph>b</paragraph>
<paragraph>c]</paragraph>

There should be an exception if this block is empty. Such blocks are still treated as selected:

<paragraph>[</paragraph> // Selection starting at the beginning of the empty block counts
<paragraph>b</paragraph>
<paragraph>c]</paragraph>

We already ignore the last selected block if the selection ends at the beginning of that block:

<paragraph>[a</paragraph>
<paragraph>b</paragraph>
<paragraph>]c</paragraph> // This selection is ignored

However, it doesn't have the above exception, i.e. if the last block is empty, it will NOT be selected:

<paragraph>[a</paragraph>
<paragraph>b</paragraph>
<paragraph>]</paragraph> // This selection is ignored

To have consistent behavior, we will improve the handling for this so that the empty blocks are selected in both cases.

@Witoso
Copy link
Member

Witoso commented Apr 3, 2023

There should be an exception if this block is empty. Such blocks are still treated as selected:

I'm a bit worried about this one. And not sure if I understand it well.

<heading2>[</heading2> // Selection starting at the beginning of the empty block counts
<imageBlock></imageBlock>
<paragraph>c]</paragraph>

But this case in style dropdown will be also confusing. It will be more visible (I will see a highlight of the selection) but the selection will still be applied when I move the cursor just above the paragraph. Right?

image

@filipsobol
Copy link
Member

Yes, currently that's the case. Interestingly, it happens on Chrome, but not in Firefox.

recording.mp4

arkflpc added a commit that referenced this issue Apr 11, 2023
Fix (engine): `Selection#getSelectedBlocks()` should ignore trailing blocks where no content is selected. The selection of such blocks is not visible to the content author and is usually there unintentionally. Closes #11585.
@CKEditorBot CKEditorBot removed the status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. label Apr 11, 2023
@CKEditorBot CKEditorBot added this to the iteration 62 milestone Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:style squad:core Issue to be handled by the Core team. type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants