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

Tour Kit: Update spotlight effect, other fixes/cleanup #58854

Merged
merged 12 commits into from
Jan 10, 2022

Conversation

chriskmnds
Copy link
Contributor

@chriskmnds chriskmnds commented Dec 6, 2021

Changes proposed in this Pull Request

  • Updates spotlight effect
    • now being reference element aware (wraps the entire reference by default)
    • customizable (can be overwritten with custom CSS props e.g. in Welcome Tour)
  • Updates Storybook examples
    • capture placement on all sides
    • resizable container for fiddling with scrolling etc.
  • Other fixes
    • issue with the arrow tip indicator
    • issue with Popper misplacing the step on mount/ initial render

Media

Default spotlight:

Kapture 2021-12-06 at 15 30 00

Customized for Welcome Tour (fixed-size spotlight, some border radius):

Screenshot 2021-12-06 at 3 33 28 PM

Testing instructions

  • Checkout branch, then yarn dev --sync from apps/editing-toolkit to sync the welcome tour to the sandbox
  • yarn run tour-kit:storybook:start in another tab for Storybook demos
  • Welcome Tour works as expected with/out ?welcome-tour-next
  • Stories work as expected

Closes #58642, #58748
Related to #58644

@chriskmnds chriskmnds added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. Welcome Tour Tour Kit labels Dec 6, 2021
@chriskmnds chriskmnds added this to the Editor welcome tour NEXT milestone Dec 6, 2021
@chriskmnds chriskmnds self-assigned this Dec 6, 2021
@github-actions
Copy link

github-actions bot commented Dec 6, 2021

@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

Comment on lines 164 to 171
useEffect( () => {
/*
* Fixes issue with Popper misplacing the instance on mount
* See: https://stackoverflow.com/questions/65585859/react-popper-incorrect-position-on-mount
*/
update && update();
setTimeout( () => setTourReady( true ) );
}, [ update ] );
Copy link
Contributor Author

@chriskmnds chriskmnds Dec 6, 2021

Choose a reason for hiding this comment

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

Bug:

Kapture 2021-12-06 at 15 45 30

Fix without tourReady (brief flicker, not always visible):

Kapture 2021-12-06 at 15 49 47

(wish there was a better way) 😐

Copy link
Contributor

Choose a reason for hiding this comment

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

I made a test with the Welcome Tour and it seems that the "flickering" is still there: https://d.pr/v/24r3Xb (look when you arrive at the third point)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Yep, see it.

I think I've found a better fix 🤞 Take another look? :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

noticing this again while testing. looking

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright. Hopefully fixed now (albeit other dragons may lurk 😬 ). Give it a few more tests? :-)

This is what we should expect:

Kapture 2021-12-08 at 14 11 48

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, now it seems to be working, well done!

const tourContainerRef = useRef( null );
const popperElementRef = useRef( null );
const [ popperElement, sePopperElement ] = useState< HTMLElement | null >( null );
Copy link
Contributor Author

@chriskmnds chriskmnds Dec 6, 2021

Choose a reason for hiding this comment

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

Recommended way for setting the popper element (useState triggers a re-render): https://popper.js.org/react-popper/v2/

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice one 💯

Copy link
Contributor

@escapemanuele escapemanuele left a comment

Choose a reason for hiding this comment

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

Looks very good to me, great job! 💪
Left a comment for a problem with setTourReady

const tourContainerRef = useRef( null );
const popperElementRef = useRef( null );
const [ popperElement, sePopperElement ] = useState< HTMLElement | null >( null );
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice one 💯

Comment on lines 164 to 171
useEffect( () => {
/*
* Fixes issue with Popper misplacing the instance on mount
* See: https://stackoverflow.com/questions/65585859/react-popper-incorrect-position-on-mount
*/
update && update();
setTimeout( () => setTourReady( true ) );
}, [ update ] );
Copy link
Contributor

Choose a reason for hiding this comment

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

I made a test with the Welcome Tour and it seems that the "flickering" is still there: https://d.pr/v/24r3Xb (look when you arrive at the third point)

@matticbot
Copy link
Contributor

This PR modifies the release build for editing-toolkit

To test your changes on WordPress.com, run install-plugin.sh editing-toolkit update/tour-kit-spotlight on your sandbox.

To deploy your changes after merging, see the documentation: PCYsg-mMA-p2

Copy link
Contributor

@escapemanuele escapemanuele left a comment

Choose a reason for hiding this comment

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

LGTM! After tests pass => :shipit:

@chriskmnds chriskmnds merged commit 4a3ab53 into trunk Jan 10, 2022
@chriskmnds chriskmnds deleted the update/tour-kit-spotlight branch January 10, 2022 11:24
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jan 10, 2022
const clipRepositionProps = referenceElement
? {
style: popperStyles?.popper,
style: {
...( clipDimensions && clipDimensions ),
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 really need the clipDimensions && check or can we just do...clipDimensions? ...null should be fine.

Copy link
Contributor Author

@chriskmnds chriskmnds Jan 12, 2022

Choose a reason for hiding this comment

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

Thanks @tyxla. Added follow-up issue. 🙇

(we are tracking in internal PT)

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, Christos 🙌

style: {
...( clipDimensions && clipDimensions ),
...popperStyles?.popper,
...( styles && styles ),
Copy link
Member

Choose a reason for hiding this comment

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

Same for styles as clipDimensions above.

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

Successfully merging this pull request may close these issues.

Tour Kit: Improve spotlight effect
4 participants