equinor / webviz-core

GNU Lesser General Public License v3.0
2 stars 3 forks source link

Latest Dash(0.40) breaks Layout component #7

Closed HansKallekleiv closed 5 years ago

HansKallekleiv commented 5 years ago

The latest released Dash version breaks the Layout component. The page names and routes appears undefined in the Dash app. This can be repduced by running the examples/map_example.py

Overview of changes in Dash: https://community.plot.ly/t/dash-0-40-0-released/21338 See the note that props.children.props are no longer available directly, but must be accessed through _dashprivate_layout.

Example quick fix:

class Layout extends Component {
    render() {

        const {children, banner, basepath} = this.props;
        const [frontPage, ...subPages] = Array.isArray(children)
            ? children
            : [children];
        const subPageProps = subPages.map(({props}) => {
            //Getting the props from _dashprivate_layout
            let props2 = props._dashprivate_layout.props
            if (props2 && !props2.title && props2.children) {
                return props2.children.props;
            }
            return props2;
        });
        const pages = subPages.map((page) => {
            //Getting the props from _dashprivate_layout
            let props = page.props._dashprivate_layout.props
            return (
                <Route
                    key={props.id}
                    path={`${basepath}/${props.id}`}
                    render={() => <PageWrapper>{page}</PageWrapper>}
                />
                )
        });
HansKallekleiv commented 5 years ago

Example fix as done for the Tabs component in dash-core-components. https://github.com/plotly/dash-core-components/blob/a24ffbda9a125e3a9084980920a9a311340f64b2/src/components/Tabs.react.js#L201

eivindjahren commented 5 years ago

Turns out that this seems not properly fixed as of yet as the tests regarding the fix is failing.

HansKallekleiv commented 5 years ago

Have a look at the fix done in the dcc.Tabs component linked in the comment above.

lightenup commented 5 years ago

A bit of nitpicking maybe: this should not be a 'bug' but an 'enhancement'. As a backend/core component a release of webviz-core comes with no guarantees of compatibility with new versions of components calling us.

That being said, work on this will continue.

fahaddilib commented 5 years ago

What is the status of this issue?

lightenup commented 5 years ago

We are having a bit of a hard time with this, but it is being worked on.