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: apply margin to wrapperStyles when drag wrapper is enabled [ALT-1293] #784

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

primeinteger
Copy link
Contributor

Purpose

Fixes the Divider component after the changes in #778 caused a regression with the Divider's position

Approach

The Divider positioning issue was due to the Divider component having Margin on by default. This issue was affecting any component that applies Margins and Relative height/width.

I updated the useComponentProps hook to apply the Margin styles to wrapperStyles while removing the Margin from the component via overrideStyles which positions the component correctly when mixing margins + relative height/width.

I adjusted the conditions in useComponentProps so that the wrapperStyles and overrideStyles will only be used when the hook is called with requireDragWrapper: true -- making sure that we aren't accidentally using wrapperStyles unless the wrapper is actually being used.

Video

Screen.Recording.2024-10-04.at.3.59.26.PM.mov

@primeinteger primeinteger requested review from a team as code owners October 4, 2024 22:05
Copy link

vercel bot commented Oct 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nextjs-marketing-demo-bug-test 🔄 Building (Inspect) Visit Preview Oct 4, 2024 10:05pm
2 Skipped Deployments
Name Status Preview Updated (UTC)
experience-builder-test-app ⬜️ Ignored (Inspect) Oct 4, 2024 10:05pm
studio-nextjs-marketing-demo ⬜️ Ignored (Inspect) Oct 4, 2024 10:05pm

Comment on lines -15 to +8
export const ContentfulDivider = (props: ContentfulDividerProps) => {
const { className } = props;
export const ContentfulDivider = ({ className = '', ...props }: ContentfulDividerProps) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This subtle change makes it so className will not be spread via ...props to the div.cf-divider element

Comment on lines -5 to -9
const styles = {
hr: css({
border: 'none',
}),
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The components package doesn't have emotion installed. I moved this style to the component's css file instead.

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.

1 participant