-
Notifications
You must be signed in to change notification settings - Fork 377
fix(Page): remove unecessary onPageResize default prop #7811
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(Page): remove unecessary onPageResize default prop #7811
Conversation
|
Preview: https://patternfly-react-pr-7811.surge.sh A11y report: https://patternfly-react-pr-7811-a11y.surge.sh |
a0fa31c to
07b1f4c
Compare
| isManagedSidebar: false, | ||
| isBreadcrumbWidthLimited: false, | ||
| defaultManagedSidebarIsOpen: true, | ||
| onPageResize: (): void => null, |
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.
Even though this technically unnecessary, we consider changes to default values breaking. Could you please update the PR to change the logic at conditional instead.
WE can open a separate issue to remove needed default in a breaking change release.
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.
@tlabaj we can't change the logic at the condition level. The condition itself is correct but the supplied values are not. The condition checks for the function's existence. And the function is always defined. So the condition is actually buggy and can never be false. That is what breaks the environment.
I've put all the details into the linked issue.
The only other option is adding a new flag that would just disable the observer. But again, looking at the condition logic, the existance of a prop is what should decide the outcome.
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.
One other alternative that would allow proper opting-out of the page resizing behavior without potentially causing breaking changes: we could update the type for onPageResize to be a union of the current type and null or something to that effect.
@Hyperkid123 do you have any thoughts regarding that potential approach? I know it isn't ideal, but I think it would be the simplest approach to getting you unblocked until our next breaking change release.
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.
Cool, I am on board with that. Let me update the PR then.
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.
@Hyperkid123 I opened issue #7861 to address the default value for our next major release.
e2d5f23 to
e12678b
Compare
tlabaj
left a comment
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
| * Returns object { mobileView: boolean, windowSize: number } | ||
| */ | ||
| onPageResize?: (object: any) => void; | ||
| onPageResize?: (object: any) => void | null; |
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.
I think this typing would still require a function, but the function could just return void | null and that the following type is what you'd really need.
| onPageResize?: (object: any) => void | null; | |
| onPageResize?: ((object: any) => void) | null; |
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.
Oh yeah, you are correct. This just changes the return type
e12678b to
5b9405c
Compare
wise-king-sullyman
left a comment
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 should be good! I will approve and merge as soon as it passes CI 🙂
wise-king-sullyman
left a comment
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.
🚀
Partially helps with: #7810