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

Connectors redraw on resize #2064

Merged
merged 3 commits into from
Oct 16, 2020
Merged

Connectors redraw on resize #2064

merged 3 commits into from
Oct 16, 2020

Conversation

bjoerge
Copy link
Member

@bjoerge bjoerge commented Oct 15, 2020

Type of change (check at least one)

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or update to documentation)
  • Maintenance
  • Other, please describe:

Does this change require a documentation update? (Check one)

  • Yes
  • No

Current behavior

Currently the connector lines are not redrawn/recalculated on resize.

Description
This makes sure the connector lines are being redrawn properly on window resize.

There are three separate commits that can be reviewed individually:

  • a9718b8 Exports a single resizeObserver instance that can be shared across different studio components (there are performance gains to be had from using a single instance instead of creating multiple). It's also exported with a bit nicer API that fits React hooks a bit better than the native ResizeObserver API.
  • 4825c6c Makes desk-tool import the shared resizeObserver instance from base instead of creating its own.
  • 55e0e5f Makes use of the same resizeObserver instance to force redraw the connector lines on resize.

Note for release
Fixes an issue with lines connecting a change with it's corresponding input not being redrawn on window/pane resize.

Checklist

  • I have read the Contributing Guidelines
  • The PR title includes a link to the relevant issue
  • The PR title is appropriately formatted: [some-package] PR title (#123)
  • The code is linted
  • The test suite is passing
  • Corresponding changes to the documentation have been made

@vercel
Copy link

vercel bot commented Oct 15, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/sanity-io/test-studio/h64fqcxkw
✅ Preview: https://test-studio-git-connectors-redraw-on-resize.sanity-io.vercel.app

Copy link
Contributor

@benedicteb benedicteb 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 to me :)

Only thing I'm thinking of is perhaps moving the resize observer stuff somewhere more general where more things can use it?

@bjoerge
Copy link
Member Author

bjoerge commented Oct 16, 2020

Only thing I'm thinking of is perhaps moving the resize observer stuff somewhere more general where more things can use it?

Yep, we can consider that. Not sure yet if this should be part of our public API, so I think we can live with importing it from @sanity/base/lib/util (as we do in desk-tool for now).

Thanks for reviewing!

@bjoerge bjoerge merged commit 02da536 into next Oct 16, 2020
@bjoerge bjoerge deleted the connectors-redraw-on-resize branch October 16, 2020 08:18
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.

2 participants