-
Notifications
You must be signed in to change notification settings - Fork 86
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(dialog-full-screen): prevent horizontal overflow due to a child Form with a sticky footer #6742
Conversation
Note: This is a temporary fix for the reported bug. I suggest revisiting the implementation of form modals in Carbon, as currently our modal components (namely Removing this decoupling will make the component's code more maintainable by avoiding child iteration/CSS overrides. And allow consumers to compose the components more freely without worrying about side-effects, such as the original bug addressed in this PR. This would most likely be a breaking change. I've raised a new ticket FE-6643 to address this. |
React.Children.toArray(children).some( | ||
(child) => | ||
React.isValidElement(child) && | ||
(child.type as React.FunctionComponent)?.displayName === | ||
Form.displayName && | ||
child.props.stickyFooter | ||
), | ||
[children] | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this hook iterates over children
, only Form
s that are passed as direct React nodes will be checked. This is why CSS styling has been used instead to account when a form is wrapped
const hasStickyFooter = useMemo( | ||
() => | ||
React.Children.toArray(children).some( | ||
(child) => | ||
React.isValidElement<FormProps>(child) && child.props.stickyFooter | ||
), | ||
[children] | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need updating as well at a future date, since any wrapped Form
s won't be recognised
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could use DOM querying here
const hasStickyFooter = () => {
const form = ref.current?.querySelector("[data-component='form']");
return form.classList.contains("sticky");
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM @Parsium, might be worth getting UX to review it as there's potentially some changes to the layout if they've rendered content above the form (not within). It's not great in master so I think these changes are fine imo (surely someone will have raised an issue by now if it wasn't) but still worth double checking
@harpalsingh for context, currently adding content above or below the sticky footer form (not within it) will break the layout: This is evident in No consumer has raised an issue for this, as we assume most are currently adding additional content within the form rather than above/below it, but are you happy for us to address it later? |
@Parsium I've approved the review, but I do feel we should eventually look at the issue if the content is added above/below the form. |
f7af444
to
7b012a3
Compare
Thanks @harpalsingh, raised this as FE-6643 |
7b012a3
to
efd0884
Compare
🎉 This PR is included in version 136.0.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
closes #6719
Proposed behaviour
Ensure when
DialogFullscreen
is rendered without padding, and contains a wrapped sticky form:that:
DialogFullscreen
's content wrapper - which caused content to overflow horizontally.Form
.Current behaviour
When
![Screenshot 2024-05-22 at 13 21 30](https://private-user-images.githubusercontent.com/18368713/332793233-9cf91866-c484-4b8b-9179-381c30412c34.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg5NjUzNzQsIm5iZiI6MTcxODk2NTA3NCwicGF0aCI6Ii8xODM2ODcxMy8zMzI3OTMyMzMtOWNmOTE4NjYtYzQ4NC00YjhiLTkxNzktMzgxYzMwNDEyYzM0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjIxVDEwMTc1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBlNGIwM2FmNjBkZTFiOTU2MjNlZGM2OGE1MWE4MzYyMTlhZmM0ZjNhMDU3NGJmZGE1ZThlYTUyOTIwMTBhM2YmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.WjMakzMtNdfJQORBJjt8tH3LjSH1IALHvVwIqmsPMEw)
DialogFullscreen
is rendered without padding, and contains a wrapped sticky form, content overflows horizontally and the vertical scrollbar is not visible:Checklist
d.ts
file added or updated if requiredQA
Testing instructions
For comparing behaviour before and after these changes, please use the following demos when manually testing:
Demo of current behaviour:
Demo of bug
Demo of new behaviour:
npm start
DialogFullscreen
's test story "With Sticky Form"disableContentPadding
prop to true