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

Change logic for restrict scroll #6632

Merged
merged 2 commits into from Feb 9, 2023

Conversation

britt6612
Copy link
Collaborator

@britt6612 britt6612 commented Feb 9, 2023

What does this PR do?

This changes the logic of when to restrictScroll

Where should the reviewer start?

LayerContainer.js

What testing has been done on this PR?

Storybook

How should this be manually tested?

import React from 'react';
import { Box, Grommet, Button, Layer, Header, Heading } from 'grommet';
import { hpe } from 'grommet-theme-hpe';

export const TargetLayer = () => {
  const [open, setOpen] = React.useState();
  const ref = React.useRef();
  const onOpen = () => setOpen(true);

  return (
    // Uncomment <Grommet> lines when using outside of storybook
    <Grommet theme={hpe}>
      <Box height="xxlarge">
        <Box
          ref={ref}
          height={{ min: 'small' }}
          gap="medium"
          width="medium"
          background="brand"
        >
          <Button label="Open" onClick={onOpen} />
          {open && (
            <Layer position="center" target={ref.current}>
              <Box
                gap="medium"
                pad="medium"
                width={{ min: 'medium' }}
                flex="grow"
              >
                <Header
                  flex={false}
                  align="start"
                  gap="small"
                  justify="between"
                >
                  <Box>
                    <Heading
                      id="layer-title"
                      level={2}
                      margin="none"
                      size="small"
                    >
                      test
                    </Heading>
                  </Box>
                </Header>
              </Box>
            </Layer>
          )}
        </Box>
      </Box>
    </Grommet>
  );
};

TargetLayer.storyName = 'Target';

TargetLayer.args = {
  full: 'min',
};

export default {
  title: 'Layout/Layer/Target',
};

Do Jest tests follow these best practices?

  • screen is used for querying.
  • The correct query is used. (Refer to this list of queries)
  • userEvent is used in place of fireEvent.
  • asFragment() is used for snapshot testing.

Any background context you want to provide?

When hitResponsiveBreakpoint is small this line
!layerTarget || hitResponsiveBreakpoint ? true : undefined turns true however when we have a layerTarget this should not be true so instead of OR this should be AND

What are the relevant issues?

Scroll issue in DS site
Closes grommet/hpe-design-system#3111

Screenshots (if appropriate)

Do the grommet docs need to be updated?

no

Should this PR be mentioned in the release notes?

yes

Is this change backwards compatible or is it a breaking change?

It does change the logic however I dont beleive it should of been OR to begin with.

Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Copy link
Collaborator

@taysea taysea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this logic.

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

Successfully merging this pull request may close these issues.

Example containers - Scrolling issue when using modal layer target
4 participants