Skip to content

View is not fully expanded if device rotate from portrait to landscape then back to portrait #531

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
elmcapp opened this issue Mar 14, 2022 · 8 comments

Comments

@elmcapp
Copy link

elmcapp commented Mar 14, 2022

Environment

bug.mov

Description

When device start in portrait mode the page shows fully. When device rotate to landscape then back to portrait mode the bottom have of the screen seem to have extra padding or is not rending all the way down to all screen.

Reproducible Demo

Rotate device from portrait view to landscape view then back to portrait view

This issue started with v5.4.15.

@elmcapp elmcapp changed the title Rotating device cause page to not fully render in portrait view View is not fully expanded if device rotate from portrait to landscape then back to portrait Mar 14, 2022
@elmcapp
Copy link
Author

elmcapp commented Mar 18, 2022

I found a fix for the issue. Would be nice if @troZee could patch this for us.
Go to file path: node_modules/react-native-pager-view/scr/utils.tsx
comment out line 30 and 31

currently

export const childrenWithOverriddenStyle = (children?: ReactNode) => {
  // Override styles so that each page will fill the parent. Native component
  // will handle positioning of elements, so it's not important to offset
  // them correctly.
  return Children.map(children, (child) => {
    const { props } = child as ReactElement;
    const newProps = {
      ...props,
      style: [
        props.style,
        {
          position: 'absolute',
          flex:1,
          left: 0,
          top: 0,
          right: 0,
          bottom: 0,
          width: undefined,
          height: undefined,
        },
      ],
      collapsable: false,
    };
    return React.cloneElement(child as ReactElement, newProps);
  });
};

to

export const childrenWithOverriddenStyle = (children?: ReactNode) => {
  // Override styles so that each page will fill the parent. Native component
  // will handle positioning of elements, so it's not important to offset
  // them correctly.
  return Children.map(children, (child) => {
    const { props } = child as ReactElement;
    const newProps = {
      ...props,
      style: [
        props.style,
        {
          position: 'absolute',
          flex:1,
          left: 0,
          top: 0,
          right: 0,
          bottom: 0,
          // width: undefined,
          // height: undefined,
        },
      ],
      collapsable: false,
    };
    return React.cloneElement(child as ReactElement, newProps);
  });
};

solved my issue

@jason-vault
Copy link

jason-vault commented Apr 8, 2022

Can confirm the same issue.

@elmcapp thanks for the legwork on pin pointing the issue!

In my case, reverting to 5.4.13 solved for me in the absence of a patch.

@vtoupet
Copy link

vtoupet commented May 11, 2022

I found a fix for the issue. Would be nice if @troZee could patch this for us. Go to file path: node_modules/react-native-pager-view/scr/utils.tsx comment out line 30 and 31

currently

export const childrenWithOverriddenStyle = (children?: ReactNode) => {
  // Override styles so that each page will fill the parent. Native component
  // will handle positioning of elements, so it's not important to offset
  // them correctly.
  return Children.map(children, (child) => {
    const { props } = child as ReactElement;
    const newProps = {
      ...props,
      style: [
        props.style,
        {
          position: 'absolute',
          flex:1,
          left: 0,
          top: 0,
          right: 0,
          bottom: 0,
          width: undefined,
          height: undefined,
        },
      ],
      collapsable: false,
    };
    return React.cloneElement(child as ReactElement, newProps);
  });
};

to

export const childrenWithOverriddenStyle = (children?: ReactNode) => {
  // Override styles so that each page will fill the parent. Native component
  // will handle positioning of elements, so it's not important to offset
  // them correctly.
  return Children.map(children, (child) => {
    const { props } = child as ReactElement;
    const newProps = {
      ...props,
      style: [
        props.style,
        {
          position: 'absolute',
          flex:1,
          left: 0,
          top: 0,
          right: 0,
          bottom: 0,
          // width: undefined,
          // height: undefined,
        },
      ],
      collapsable: false,
    };
    return React.cloneElement(child as ReactElement, newProps);
  });
};

solved my issue

FYI it worked for me.

@andreialecu
Copy link
Collaborator

This should be fixed by #565

@tradebulls
Copy link

@andreialecu It does not fix for me with #565 . However my issue was resolved with the solution given by @elmcapp . Can we consider it as a fix?

@andreialecu
Copy link
Collaborator

#565 initially fixed it but it regressed again in #567

I'm working on a new fix in #580

@tradebulls
Copy link

@andreialecu Thanks for doing so 👍

@chandresh8187
Copy link

i have same issue in latest version of react-native-pager-view

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants