Skip to content

use forwardref and change buttonref #6613

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

Merged
merged 2 commits into from
Jan 30, 2023

Conversation

britt6612
Copy link
Collaborator

What does this PR do?

Where should the reviewer start?

DropContainer.js
DropButton.js

What testing has been done on this PR?

storybook

How should this be manually tested?


      <Box margin={{ left: 'large', top: '200px' }} direction="row">
        <DropButton
          badge={badge}
          dropAlign={{ left: 'left', top: 'bottom' }}
          label='hello'
          icon={<Columns />}
          dropContent={
            <Box pad="medium">
              <Button
                label="Toggle badge"
                onClick={() => setBadge((prev) => !prev)}
              />
            </Box>
          }
        />
      </Box>

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?

Re-rendering the Button when adding a badge or tip causes the DropButton's buttonRef.current to change. DropButton passes the initial buttonRef.current to DropContainer but doesn't pass the new one when the Button re-renders for the badge.

more comments here

What are the relevant issues?

closes #6539

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?

backwards compatible

@britt6612 britt6612 requested a review from jcfilben January 30, 2023 19:36
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!

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.

DropButton loses drop target location when badge changes while the menu is open
3 participants