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

Sibling inserter click redirect: add e2e tests #19729

Merged
merged 2 commits into from
Jan 20, 2020

Conversation

ellatrix
Copy link
Member

Description

See #19719. This PR fixes the visible inserter tooltip from the inserter above a selected block. It also adds e2e tests for the whole feature.

How has this been tested?

Screenshots

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR. .

@ellatrix ellatrix added [Type] Bug An existing feature does not function as intended [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... labels Jan 17, 2020
@ellatrix ellatrix requested a review from aduth January 17, 2020 17:40
Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

This fixes a lot of the issues I was seeing with #19719 👍

It's the same on master, but one thing I notice is there must be a very small gap somewhere, or a specific browser difference in transitioning from the contenteditable to the wrapper (with cursor: text) that causes the cursor to flicker. It is very subtle, but quite nagging when you finally notice it:

https://cloudup.com/cn1pGnLf6hC

One thought I have is: Should we just want the entire paragraph to be styled as cursor: text so there is no transition? It makes me wonder as well, considering that not every block is text based, whether defaulting to cursor: text in these gaps is a sensible default, especially for more layout-heavy posts/pages. I guess this is the same question on the spectrum of the block editor behaving like a text editor vs. a layout arranger. In any case, if we did decide to move this to be a style of the paragraph block specifically, it would serve as something of a solution to this potential concern.

const x = paragraphRect.x + ( 2 * paragraphRect.width / 3 );
const y = paragraphRect.y + paragraphRect.height + 10;

await page.mouse.move( x, y, { steps: 10 } );
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the steps?

Copy link
Member Author

Choose a reason for hiding this comment

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

Apparently not. :)

await page.keyboard.type( '2' );
await page.keyboard.press( 'ArrowUp' );

const paragraph = await page.$( '[data-type="core/paragraph"]' );
Copy link
Member

Choose a reason for hiding this comment

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

What is this logic doing? Can we add an inline comment?

e.g.

Suggested change
const paragraph = await page.$( '[data-type="core/paragraph"]' );
// Find a point outside the paragraph between the blocks where it's not
// expected that the sibling inserter would be placed.
const paragraph = await page.$( '[data-type="core/paragraph"]' );

The exercise of writing this out has me wondering though: The logic as implemented isn't really specific to choosing a point where the inserter isn't going to be, it's only "hoping" that because the sibling inserter is at the centerpoint, that a point 2/3 of the horizontal width of a paragraph would be enough displaced from the sibling inserter to be able to click on.

Could we instead select the inserter element itself, and do something like x = inserterBox.right + 1; ?

Copy link
Member Author

Choose a reason for hiding this comment

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

The inserter isn't there yet at this time. We're moving the mouse so it appears in the right place. I added your (adjusted) comment and updated the code.

await page.keyboard.type( '1' );
await page.keyboard.press( 'Enter' );
await page.keyboard.type( '2' );
await page.keyboard.press( 'ArrowUp' );
Copy link
Member

Choose a reason for hiding this comment

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

What's the ArrowUp for? Is it just to get the contextual toolbar out of the way? Can we leave a comment? Is there another way we can "deselect" the block to have a stronger guarantee the toolbar isn't there?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's to select the first paragraph since we're testing if the selection moves to the second.

@ellatrix
Copy link
Member Author

Should we just want the entire paragraph to be styled as cursor: text so there is no transition?

I don't think that's possible. We're not styling the paragraph itself but the areas between the paragraphs.

We can fine tune the cursor style later. Alternatively, we can make it the same as the one for a button.

The flicker you see is, I think, caused by the inserter appearing after a small delay.

@ellatrix ellatrix merged commit c1e7575 into master Jan 20, 2020
@ellatrix ellatrix deleted the fix/sibling-inserter-e2e branch January 20, 2020 08:25
@ellatrix ellatrix added this to the Gutenberg 7.3 milestone Jan 20, 2020
opacity: 0;
pointer-events: none;
Copy link
Member

Choose a reason for hiding this comment

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

I've noticed one negative impact of this style: When trying to scroll the block list, if the cursor happens to be placed over the sibling inserter when using the scroll wheel, the scroll will not happen.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, that's not good. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, it seems to be happening before this change as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that the pointer is over a Popover, which won't scroll the page.

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 notice the same thing with the block toolbar. It's not possible to scroll with the pointer over it.

Copy link
Member Author

Choose a reason for hiding this comment

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

The strange thing is that it is rendered in the scroll container.

Copy link
Member

Choose a reason for hiding this comment

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

Is there anything in the popover rendering that would be preventing the scroll? pointer-events or event.preventDefault ?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not immediately obvious to me. I commented out all pointer-events rules and it's still not scrolling. Also no scroll preventing I think.

Copy link
Member

Choose a reason for hiding this comment

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

The strange thing is that it is rendered in the scroll container.

In some further debugging:

  • It is part of the container where scrolling is applied (.edit-post-editor-regions__content)
  • But it's not part of the content which is causing the scroll (edit-post-visual-editor)

It's not immediately clear to me what the expected behavior here would be, but this could explain why the scroll doesn't happen.

image

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 found the issue. The popover container's position is fixed which means it's positioned relative to the viewport. Relatively positioning the scroll container won't help unless we absolutely position the popover. It sounds like this will need some adjustment in the Popover component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants