Skip to content

Routing show wrong layout #162

Open
Open

Description

@mako87

Describe the bug
Sometimes, when routing my view component show a wrong layout then I expect.
But, If I resize the window manually, layout return normal automatically.

<Window
              size={minSize}
              minSize={minSize}
              styleSheet={styleSheet}
      >
<View id="container">
          <MemoryRouter>
            <View id="left">
              <Menu />
            </View>
            <View id="right">
              <View id="section">
                <AppRoutes />
              </View>
              <View id="footer">
                <Footer />
              </View>
            </View>
          </MemoryRouter>
        </View>
</Window>

const styleSheet = `
    #container {
      flex: 1;
      flex-direction: row;
      min-height: '100%';
      min-width: '100%';
    }
    #left {
      flex-grow: 1;
      min-height: '100%';
      min-width: '30%';
      padding: 10px;
      background-color: white;
      border: 1px solid yellow;
    } 
    #right {
      flex-grow: 10;
      min-height: '100%';
      min-width: '70%';
      padding: 20px;
      border: 1px solid black;
    }
    
    #section {
      border: 1px solid red;
      min-width: '100%';
      min-height: '80%';
    }
    
    #footer {
      border: 1px solid blue;
      min-height: '20%';
    }
`;

Normal Layout

image

Wrong layout

image

Desktop (please complete the following information):

  • OS: Windows 10
  • NodeGUI version: 0.15.2
  • React NodeGUI version: 0.5.0

Activity

  1. agg23 commented on May 31, 2020

    @agg23
    Contributor

    I am experiencing a similar situation where initially, the layout renders correctly, but changing the component tree breaks the layout in a similar manner. Any window size change restores the proper positions.

  2. agg23 commented on Jun 1, 2020

    @agg23
    Contributor

    Not sure if this has to do with your issue, but for me it appears to be the sizing of ScrollArea. Somehow, the sizing appears to be indeterminate, so changing child nodes shrinks the ScrollArea.

    Edit: Turns out the CRA template uses an older version of both nodegui and react-nodegui. Upgrading fixed my issues.

  3. agg23 commented on Jun 2, 2020

    @agg23
    Contributor

    Minimal repro of arbitrary sizing behavior:

    import {
      Window,
      hot,
      View,
      Button,
      useEventHandler,
    } from "@nodegui/react-nodegui";
    import React, { useState } from "react";
    import { QPushButtonSignals } from "@nodegui/nodegui";
    
    const minSize = { width: 500, height: 520 };
    const App = () => {
      const [toggle, setToggle] = useState(false);
    
      const handler = useEventHandler<QPushButtonSignals>(
        {
          clicked: () => setToggle((prev) => !prev),
        },
        []
      );
    
      return (
        <Window windowTitle="Hello 👋🏽" minSize={minSize}>
          <View style={outer}>
            <View style={inner}>
              <Button
                style={button}
                on={handler}
                text={toggle ? "Toggle Off" : "Toggle On"}
              />
            </View>
            <Button text="Outer Content" />
          </View>
        </Window>
      );
    };
    
    const outer = `
      background-color: red;
    `;
    
    const inner = `
      background-color: blue;
    `;
    
    const button = `
      background-color: green;
    `;
    
    export default App;
    

    Initial Render:
    Screen Shot 2020-06-02 at 12 45 49 PM

    First Click:
    Screen Shot 2020-06-02 at 12 46 50 PM

    After Resizing:
    Screen Shot 2020-06-02 at 12 47 26 PM

  4. Eeems commented on Dec 7, 2020

    @Eeems
    Contributor

    I'm also experiencing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions