Skip to content

Conversation

jcfilben
Copy link
Collaborator

@jcfilben jcfilben commented Jan 27, 2023

What does this PR do?

Changed Drop behavior to flip the drop if part of the drop isn't visible and there is more room in the opposite direction.

I also set the responsive prop to true by default. This aligns with what the documentation shows.

Where should the reviewer start?

What testing has been done on this PR?

How should this be manually tested?

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?

What are the relevant issues?

Closes #6495

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

… visible and there is more room in the opposite direction
@jcfilben jcfilben requested a review from britt6612 January 27, 2023 18:50
@taysea taysea self-requested a review January 30, 2023 17:08
@britt6612
Copy link
Collaborator

one thing I saw in the storybook is since we have responsive = true, now set which is fine since docs stated that responsive is default to true thinking we need to add responsive={false} to this story.

const percentVisibleAreaBelow =
100 - (targetRect.bottom / windowHeight) * 100;
const alignToTop = align.top === 'top';
const switchTop = !alignToTop ? targetRect.top : targetRect.bottom;
Copy link
Collaborator

Choose a reason for hiding this comment

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

just opinion not sure about the naming for switchTop

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree the name is confusing. I changed it to switchTarget since this props is new target position the drop will be aligned to if we flip the drop.

// when percentVisibleAreaBelow>20%.

if (windowHeight === top || percentVisibleAreaBelow <= 20) {
if (
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we add a new comment for this section
the old comment was clear but since the behavior changed just for future reference

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a comment

Copy link
Collaborator

@britt6612 britt6612 left a comment

Choose a reason for hiding this comment

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

Just a few comments but I think the direction of this approach is a good change.

@jcfilben
Copy link
Collaborator Author

one thing I saw in the storybook is since we have responsive = true, now set which is fine since docs stated that responsive is default to true thinking we need to add responsive={false} to this story.

Changed the story to have responsive={false}

Copy link
Contributor

@ericsoderberghp ericsoderberghp left a comment

Choose a reason for hiding this comment

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

A few initial comments to get started with.

} else {
({ bottom } = targetRect);
}
bottom = alignToTop ? targetRect.bottom : targetRect.top;
maxHeight = bottom;
container.style.maxHeight = `${maxHeight}px`;
Copy link
Contributor

Choose a reason for hiding this comment

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

How come sometimes we set container.style.maxHeight without honoring preserveHeight? I was expecting we'd only set the style within if (!preserveHeight) { later down.

const switchTarget = !alignToTop
? targetRect.top
: targetRect.bottom;
top = alignToTop ? targetRect.top : targetRect.bottom;
Copy link
Contributor

Choose a reason for hiding this comment

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

My head is a bit confused trying to keep track of all of this. I'm wondering if there's a way to make it a bit clearer, perhaps by renaming some variables, or perhaps by restructuring the code. For instance, would it be clearer if we just checked if (align.top === 'top') { and then put everything for that case under it and then } else { for the other version, rather than trying to merge them together?

Copy link
Collaborator

@britt6612 britt6612 left a comment

Choose a reason for hiding this comment

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

alot cleaner 🙌 and thanks for adding comment

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.

Good work!

@ericsoderberghp ericsoderberghp merged commit 648f442 into grommet:master Feb 1, 2023
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.

Dateinput component gets cropped for certain resolution, ideally 100% of the date input component should be seen in viewport.
4 participants