Skip to content
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

Routing show wrong layout #162

Open
mako87 opened this issue Mar 11, 2020 · 3 comments
Open

Routing show wrong layout #162

mako87 opened this issue Mar 11, 2020 · 3 comments

Comments

@mako87
Copy link

@mako87 mako87 commented Mar 11, 2020

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
@agg23
Copy link
Contributor

@agg23 agg23 commented May 31, 2020

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.

@agg23
Copy link
Contributor

@agg23 agg23 commented Jun 1, 2020

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.

@agg23
Copy link
Contributor

@agg23 agg23 commented Jun 2, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.