mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-26 06:47:17 +10:00
Menu needs to wait mounting to calculate dimensions reliably
This commit is contained in:
parent
e01dfa0258
commit
740e2f24bc
1 changed files with 6 additions and 2 deletions
|
|
@ -38,7 +38,7 @@ class Menu extends Component {
|
|||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = { isOpen: false };
|
||||
this.state = { isOpen: false, ready: false };
|
||||
|
||||
const { isOpen, onToggleActive } = props;
|
||||
const isIndependentMenu = isOpen === null && onToggleActive === null;
|
||||
|
|
@ -60,6 +60,10 @@ class Menu extends Component {
|
|||
this.menu = null;
|
||||
this.menuContent = null;
|
||||
}
|
||||
componentDidMount() {
|
||||
// Menu needs to know about DOM before it can calculate it's size proberly.
|
||||
this.setState({ ready: true });
|
||||
}
|
||||
|
||||
onBlur(event) {
|
||||
// FocusEvent is fired faster than the link elements native click handler
|
||||
|
|
@ -168,7 +172,7 @@ class Menu extends Component {
|
|||
const { className, rootClassName } = this.props;
|
||||
const rootClass = rootClassName || css.root;
|
||||
const classes = classNames(rootClass, className);
|
||||
const menuChildren = this.prepareChildren();
|
||||
const menuChildren = this.state.ready ? this.prepareChildren() : null;
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue