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: changing month or day in post publish date closes the popover. #17201

Conversation

jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented Aug 26, 2019

Description

Fix: #17042

Currently, changing the month using previous/next buttons in the date picker closes the popover making it unusable and making post scheduling an arduous task.

The problem happens because when we click previous/next buttons, a focus lose occurs. I did lots of debugging, and I did not found a cause for this in our code. We will need an upstream commit on react-dates. But until then, this PR uses onPrevMonthClick/onNextMonthClick events to force the focus to be inside the focusable region.

How has this been tested?

I checked that I could change the day or month in the post scheduler, and the popover does not close.

@jorgefilipecosta jorgefilipecosta added [Type] Bug An existing feature does not function as intended [Priority] High Used to indicate top priority items that need quick attention labels Aug 26, 2019
Copy link
Member

@noisysocks noisysocks left a comment

Choose a reason for hiding this comment

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

When I test this PR I notice that you can no longer dismiss the date picker by clicking anywhere on the Document sidebar. There are similar problems with the inserter and the More menus.

I don't think that this fixes the root cause of the issue which is that there's a focus loss when the Next month button is clicked. It's the loss of focus which is causing withFocusOutside to (correctly) close the menu.

You can see what I mean by:

  1. Open DevTools.
  2. Open the schedule date picker.
  3. Click the Next month button.
  4. In DevTools, run: document.activeElement

document.activeElement should be the Next month button, but it is not.

@gziolo gziolo added the [Package] Components /packages/components label Aug 27, 2019
@jorgefilipecosta jorgefilipecosta force-pushed the fix/changing-month-or-day-in-post-scheduler-closes-the-popover branch from 2c4fc83 to 9ed00a8 Compare August 27, 2019 16:17
@jorgefilipecosta
Copy link
Member Author

Thank you for the reviews @noisysocks, @epiqueras. It seems the previous fix was invalid. And I was not able to find a "correct" fix. Probably we should debug the problem upstream on react dates and add a commit there that avoids the focus lose. But until then I commit a fix that essentially guarantees that when we click next/prev month, the focus is kept on the date picker focusable region.

@jorgefilipecosta jorgefilipecosta dismissed stale reviews from noisysocks and epiqueras August 27, 2019 16:56

Updated the fix used.

packages/components/src/date-time/date.js Outdated Show resolved Hide resolved
packages/components/src/date-time/date.js Outdated Show resolved Hide resolved
@jorgefilipecosta jorgefilipecosta merged commit 5973603 into master Aug 27, 2019
@jorgefilipecosta jorgefilipecosta deleted the fix/changing-month-or-day-in-post-scheduler-closes-the-popover branch August 27, 2019 17:32
@noisysocks
Copy link
Member

Cool hack! Thanks @jorgefilipecosta! 👍

jorgefilipecosta added a commit that referenced this pull request Aug 28, 2019
* Fix: changing month or day in post publish date closes the popover.

* Update packages/components/src/date-time/date.js

Co-Authored-By: Enrique Piqueras <[email protected]>

* Update packages/components/src/date-time/date.js

Co-Authored-By: Enrique Piqueras <[email protected]>
gziolo pushed a commit that referenced this pull request Aug 29, 2019
* Fix: changing month or day in post publish date closes the popover.

* Update packages/components/src/date-time/date.js

Co-Authored-By: Enrique Piqueras <[email protected]>

* Update packages/components/src/date-time/date.js

Co-Authored-By: Enrique Piqueras <[email protected]>
gziolo pushed a commit that referenced this pull request Aug 29, 2019
* Fix: changing month or day in post publish date closes the popover.

* Update packages/components/src/date-time/date.js

Co-Authored-By: Enrique Piqueras <[email protected]>

* Update packages/components/src/date-time/date.js

Co-Authored-By: Enrique Piqueras <[email protected]>
@gziolo gziolo added this to the Gutenberg 6.4 milestone Aug 30, 2019
@youknowriad
Copy link
Contributor

This one deserves an e2e test :)

@jorgefilipecosta
Copy link
Member Author

This one deserves an e2e test :)

Hi @youknowriad, I totally agree, I will look into creating a simple e2e test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Post scheduler: Cannot move to prev/next month
5 participants