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

feat(modals): introduce new TooltipModal component #828

Merged
merged 11 commits into from
Aug 14, 2020

Conversation

austingreendev
Copy link
Contributor

@austingreendev austingreendev commented Aug 10, 2020

Description

This PR introduces the new TooltipModal component. Overall, the structure and semantics align with the existing Modal implementation, with an updated focus on relative positioning.

2020-08-10 10-59-23 2020-08-10 11_00_06

Detail

Testing

We have begun seeing ts-jest warnings due to our Node version. I've updated the tsconfig.test.json file to resolve these warnings.

Popper.js v2

This is the first package to consume Popper v2 and the updated usePopper hook. Overall this feels like a significant improvement to Popper v1. There are some differences in how modifiers are applied, including default offsets. We now include a default 8px offset in all directions (this is customizable by the consumer).

The required testing syntax also differs from Popper v1, but seems more robust and requires no mocking.

Re-Positioning and maintaining focus

A key requirement for this component is to be re-positioned without a full DOM re-render. This allows focus to be retained within the focus-jail and stay located on any navigation buttons.

Checklist

  • 👌 design updates are Garden Designer approved (add the
    designer as a reviewer)
  • 🌐 Styleguidist demo is up-to-date (yarn start)
  • ⬅️ renders as expected with reversed (RTL) direction
  • 🤘 renders as expected with Bedrock CSS (?bedrock)
  • ♿ analyzed via axe and evaluated using VoiceOver
  • 💂‍♂️ includes new unit tests
  • 📝 tested in Chrome, Firefox, Safari, Edge, and IE11

@coveralls
Copy link

coveralls commented Aug 10, 2020

Coverage Status

Coverage increased (+0.03%) to 96.385% when pulling ccf5835 on agreen/tooltip-modal into 3fa59f9 on main.

@zendesk-garden zendesk-garden temporarily deployed to staging August 10, 2020 04:44 Inactive
@austingreendev austingreendev requested review from m-lai and a team August 10, 2020 17:57
@austingreendev austingreendev marked this pull request as ready for review August 10, 2020 17:57
@zendesk-garden zendesk-garden temporarily deployed to staging August 10, 2020 18:29 Inactive
@zendesk-garden zendesk-garden temporarily deployed to staging August 11, 2020 17:26 Inactive
Copy link
Member

@jzempel jzempel left a comment

Choose a reason for hiding this comment

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

There seems to be a bug I can reproduce with the example:

  1. Click to expand a step
  2. Scroll up until the TooltipModal shifts position to the top of the button
  3. Keep scrolling up and down

Result: dual scrollbars appear with inability to scroll the page until the user hits esc

packages/modals/src/styled/StyledTooltipWrapper.ts Outdated Show resolved Hide resolved
packages/modals/src/styled/StyledTooltipModalTitle.ts Outdated Show resolved Hide resolved
packages/modals/src/styled/StyledTooltipModalFooterItem.ts Outdated Show resolved Hide resolved
packages/modals/src/styled/StyledTooltipModalFooterItem.ts Outdated Show resolved Hide resolved

const COMPONENT_ID = 'modals.tooltip_modal.title';

export const StyledTooltipModalTitle = styled.div.attrs({
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure these align as well as FooterItem does. TooltipModal isn't a variant of Modal. We would have to override several styles to make it fit. i.e. as Modal evolves we don't want TooltipModal to change with it

Copy link
Member

Choose a reason for hiding this comment

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

For all of these comments, I was suggesting that the TooltipModal becomes the new baseline and Modal extends from that. I might've missed something in the comparison, but it seemed that all properties represented in TooltipModal were also represented (and nearly 100% the same) in Modal.

packages/modals/examples/tooltip-modal.md Outdated Show resolved Hide resolved
packages/modals/examples/tooltip-modal.md Outdated Show resolved Hide resolved
packages/modals/examples/tooltip-modal.md Outdated Show resolved Hide resolved
@m-lai
Copy link

m-lai commented Aug 12, 2020

@Austin94 Looking good so far on the visual front. Do we have to retain the disabled button in Step 1? Feels a bit odd.

Also, what would happen if the tooltip modal is implemented near the edge of a screen? Presumably it would adjust its position instead of cutting off?

@austingreendev
Copy link
Contributor Author

Do we have to retain the disabled button in Step 1? Feels a bit odd

This was modeled after some in-product usages. I'll remove it for the first step.

Also, what would happen if the tooltip modal is implemented near the edge of a screen?

Depending on the position value provided it would automatically change position or adjust itself against the body size to avoid a cutoff.

@austingreendev
Copy link
Contributor Author

@jzempel @hzhu I think I've addressed a good chunk of the comments.

Regarding the double-scrollbars, I've included logic similar to Modal by adding overflow: hidden styling to the body element whenever a TooltipModal is displayed.

@zendesk-garden zendesk-garden temporarily deployed to staging August 12, 2020 19:05 Inactive
Copy link
Contributor

@hzhu hzhu left a comment

Choose a reason for hiding this comment

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

LGTM this is fantastic!

@zendesk-garden zendesk-garden temporarily deployed to staging August 12, 2020 20:53 Inactive
@zendesk-garden zendesk-garden temporarily deployed to staging August 12, 2020 21:46 Inactive
@m-lai
Copy link

m-lai commented Aug 13, 2020

Thanks @Austin94 ! One other question - I noticed the padding between the start of the arrows and the edge of the tooltip modal is smaller than what we have in the Sketch files - was this intentional? It looks kind of tight IMO compared to Sketch but I'd like to update the Sketch file to be consistent with code either way

https://share.getcloudapp.com/E0unzmA0

@austingreendev
Copy link
Contributor Author

@m-lai I based the original sizing off of the large Tooltip, but it looks like I should have used the extra-large. I've updated the arrow sizing and margin to align with the sizes shown in Abstract.

@zendesk-garden zendesk-garden temporarily deployed to staging August 14, 2020 18:57 Inactive
@austingreendev austingreendev merged commit 15e1ba3 into main Aug 14, 2020
@austingreendev austingreendev deleted the agreen/tooltip-modal branch August 14, 2020 20:23
@m-lai
Copy link

m-lai commented Aug 18, 2020

@m-lai I based the original sizing off of the large Tooltip, but it looks like I should have used the extra-large. I've updated the arrow sizing and margin to align with the sizes shown in Abstract.

Cheers!!

position: static !important; /* [1] */

padding: ${props => props.theme.space.base * 5}px;
width: 400px;
Copy link
Contributor

@hzhu hzhu Aug 31, 2021

Choose a reason for hiding this comment

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

Hard coding a width here forces consumers to override CSS when 400px doesn't work for their context. Currently running into this situation using the tooltip modal in the color picker and color swatch dialogs.

https://github.com/zendeskgarden/react-components/blob/main/packages/colorpickers/src/styled/ColorpickerDialog/StyledTooltipModal.ts#L16

Copy link
Member

Choose a reason for hiding this comment

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

I believe the solution is to !important as we do with

width: ${props => COLORPICKER_WIDTH + props.theme.space.base * 10}px !important; /* [1] */
.

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

Successfully merging this pull request may close these issues.

6 participants