-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Dialog] Incorrect paddingTop when opening Dialog with dynamic content #1676
Comments
I'm experiencing a similar issue. The first time I render a Dialog paddingTop is correct, but if the component update, paddingTop is incorrect. |
I'm facing the same issue. You can use |
@aslauris your solution is nice,but when I show images in a dialog,I don't know when to call the dispatchEvent function because of load time of image.has any idea? |
@Ben07 you can probably set call window.dispatchEvent from inside the 'componentWillUpdate' lifecycle callback. i assume that gets called as the image loads, but I'm not sure. |
@rhythnic thanks,I set call window.dispatchEvent inside the 'componentDidUpdate' and use DIV tag which has Immutability height to wrap these images.It's works. |
Any advice on solving this? I'd be happy to submit a PR if given direction. |
@morenoh149 you can fix it by overriding the dialog styles: #2322 (comment). There's not really a perfect solution at the moment. You could also try something like this: <Dialog
contentStyle={ styles.dialogContent }
bodyStyle={ styles.dialogBody }
style={ styles.dialogRoot }
repositionOnUpdate={ false }
/>
var styles = {
dialogRoot: {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
paddingTop: 0
},
dialogContent: {
position: 'relative',
width: '90%',
maxWidth: 500
},
dialogBody: {
paddingBottom: 0
}
}; |
@morenoh149 : were you able to solve the issue with the above suggestion? Let me know if that works |
@grimor : was this issue resolved for you? |
haven't had a chance. sorry. |
@tintin1343 I'm still experiencing a similaire issue with dialog and dynamic content. |
@oliviertassinari : I can look into it. Could you post your findings here? I can take it over. I actually made a change in the dialog PaddingTop attribute in the DatePicker PR i told you about. |
@oliviertassinari @tintin1343 FYI guys I am currently experimenting with some |
@oliviertassinari : Was this fixed with the PR? |
@tintin1343 No, I was referring to a related issue. |
@echenley thanks for #1676 (comment). I had to do
|
can we just have a prop to disable the vertical center? |
Forking @echenley's ideas: import React, {
Component,
} from "react";
import Dialog from "material-ui/Dialog";
const styles = {
dialogRoot: {
display: "flex",
alignItems: "center",
justifyContent: "center",
paddingTop: 0
},
dialogContent: {
position: "relative",
width: "80vw",
transform: "",
},
dialogBody: {
paddingBottom: 0
}
};
export default class CustomDialog extends Component {
render () {
const { ...props } = this.props;
return (
<Dialog
{...props}
contentStyle={ styles.dialogContent }
bodyStyle={ styles.dialogBody }
style={ styles.dialogRoot }
repositionOnUpdate={ false }
/>
);
}
} I'm not sure why this is not the default. |
Guys, I'm trying to pass in the "styles.dialogRoot" into the Dialog component with just a "paddingTop" of 0, and it just doesn't seem to get applied into the Dialog. I'm doing exactly the same steps as above, just applying the paddingTop. Any ideas why style isn't working? |
Yeah same actually, paddingTop does not seem to get reset... I really enjoy almost all components of material-ui but this one is really limited.. |
@nickbae91 my guess is you use |
see here: https://github.com/callemall/material-ui/blob/master/src/Dialog/Dialog.js#L218 the padding get re-set in repositionOnUpdate case |
This is somehow related to animations. One can manually trigger Currently, my workaround is this. But you'll notice how componentDidUpdate: function () {
setTimeout(() => {
window.dispatchEvent(new Event('resize'));
}, 500);
}, |
I think the dialog could be centered vertically by using flexbox patterns withouth calculating padding-top. However, I fixed it with
Doing the same using inline styles does not work. Is it overwritten by the calculated value? Because my dialog has so much content that it shouldn't have any top-padding, this is good enough as a workaround until this bug is fixed. |
That issue has been solved on the |
I still have this issue on v0.17.0 could you please confirm this fix for this version? thanks. |
The issue is still present on the 0.x.x releases. We don't have the resources to maintained two versions. If the |
You can use this props for Dialog |
@kamran-koupayi: repositionOnUpdate does not work in my case. The child (content) of the dialog is updated but the dialog does not detect it. |
I've just fixed an issue with our application where this was happening. My fix is along these lines (no point in showing you the code its exceptionally specific to our situation) in the dialog code : in the child : ... the theory is that when the child updates its state data, it fires the callback which updates the parent, but that only happens when the specific data I need watching changes. hope thats useful to someone.... |
When I have structure like that
Where
MediaList
contain grid of images. It gets paddingTop calculated incorrectlyBut, on second
_positionUpdate()
call it have proper positioning.I suppose that images get calculated their dimensions later than modal (I've set
width
andheight
properties on<img>
tag)I'll try to work on PR on that, but maybe someone is smarter than me :)
The text was updated successfully, but these errors were encountered: