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

[Overlay] New Overlay CSS plays nice with centered, scrollable dialogs #1373

Merged
merged 20 commits into from
Aug 10, 2017

Conversation

llorca
Copy link
Contributor

@llorca llorca commented Jul 21, 2017

Fixes #552, Fixes #1240, Fixes #1313

Checklist

  • Include tests
  • Update documentation

Reviewers should focus on:

  • New overlay CSS
  • Updated dialog CSS

What happened

Dialog component now renders a .pt-dialog-container wrapper as its root element which centers the .pt-dialog in a viewport-covering flex container. This provides super reliable centering behavior (#552) and much improved scrolling support (though some issues are still present like #1008).

@llorca llorca requested review from cmslewis and giladgray July 21, 2017 22:14
@blueprint-bot
Copy link

Fix Sass linting

Preview: documentation
Coverage: core | datetime

@cmslewis
Copy link
Contributor

Take a look at the Overlay example: the background color is flickering and ending up darker after a moment:

2017-07-24 14 23 07

Copy link
Contributor

@cmslewis cmslewis left a comment

Choose a reason for hiding this comment

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

Code looks good to me.

@llorca
Copy link
Contributor Author

llorca commented Jul 24, 2017

@cmslewis Hmm, what browser? I can't repro on Chrome nor Firefox

@blueprint-bot
Copy link

Disable text selection on backdrop

Preview: documentation
Coverage: core | datetime

@llorca
Copy link
Contributor Author

llorca commented Jul 24, 2017

Just added user-select: none to the backdrop. It fixes this bug in Firefox where mousing down on the backdrop selects the text below:
screen recording firefox

@blueprint-bot
Copy link

Even out toast margin / toast container padding

Preview: documentation
Coverage: core | datetime

Copy link
Contributor

@giladgray giladgray 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, we did a great job here! ✋
a few little cleanups and should be good to go

}

private cancelContextMenu = (e: React.SyntheticEvent<HTMLDivElement>) => e.preventDefault();

private handleBackdropContextMenu = (e: React.MouseEvent<HTMLDivElement>) => {
// HACKHACK: React function to remove from the event pool (not sure why it's not in typings #66)
(e as any).persist();
// HACKHACK: React function to remove from the event pool
Copy link
Contributor

Choose a reason for hiding this comment

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

actually this is not a HACKHACK, it's expected usage if you want to use an event in a callback. can you remove the HACKHACK keyword but leave the rest of comment?

z-index: $pt-z-index-overlay;
// add bottom margin for overflow scrolling scenarios
margin-bottom: $pt-grid-size * 2;
margin: ($pt-grid-size * 3) 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

$dialog-margin please

<div className={classNames(Classes.DIALOG, this.props.className)} style={this.props.style}>
{this.maybeRenderHeader()}
{this.props.children}
<div className="pt-dialog-container">
Copy link
Contributor

Choose a reason for hiding this comment

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

Classes.DIALOG_CONTAINER

@@ -56,4 +56,4 @@ and we'll take care of the rest.
<Overlay className="pt-overlay-scroll-container" ... />
```

The `Dialog` component does this automatically internally, except when it is used `inline`.
The `Dialog` component applies this CSS class automatically internally.
Copy link
Contributor

Choose a reason for hiding this comment

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

remove word "internally"

ref={this.refHandlers.container}
>
{transitionGroup}
</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

should be safe to undo this formatting, nothing actually changed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Much easier to parse next to the corresponding else block right after, don't you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

can't see that other block in the default diff here but you're right

@@ -120,6 +120,10 @@ $popover-width: $pt-grid-size * 35 !default;
.pt-transition-container {
@include popover-inline-position();
}

.pt-overlay-inline {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a comment why this is necessary? so we don't come wondering later. might require re-deriving why we had to add this.

@giladgray giladgray requested a review from adidahiya July 25, 2017 20:49
@blueprint-bot
Copy link

Address nits and comments

Preview: documentation
Coverage: core | datetime

@blueprint-bot
Copy link

Address nits and comments

Preview: documentation
Coverage: core | datetime

@adidahiya
Copy link
Contributor

Am I supposed to be able to scroll the background when a dialog is open like this?

2017-07-26 12 04 02

@llorca
Copy link
Contributor Author

llorca commented Jul 26, 2017

@adidahiya I suppose you opened the dialog and then hovered the primary button to view the tooltip? In that case, yes it's expected. Separate bug, there's a fix in review now: #1369

@giladgray
Copy link
Contributor

giladgray commented Jul 26, 2017

@adidahiya @llorca: just merged master with fix for background scrolling. hopefully that'll work as expected now. edit: confirmed works

@adidahiya please continue reviewing for potential workspace breaks!

@blueprint-bot
Copy link

Merge branch 'master' of github.com:palantir/blueprint into al/dialog-flex

Preview: documentation
Coverage: core | datetime

@blueprint-bot
Copy link

revert padding/margin changes for legacy compat

Preview: documentation
Coverage: core | datetime

@giladgray
Copy link
Contributor

@adidahiya tested with multiple different versions of blueprint CSS and fixed a few loose ends. the new styles now include a small patch to reset position on new Dialogs that use the .pt-dialog-container element. i also reverted changes we made to padding/margin on Dialog inner elements cuz those def don't play nice with old versions. looking good now!

@blueprint-bot
Copy link

actually hold up we can let the old version provide the old transitions

Preview: documentation
Coverage: core | datetime

…r scrolling

requires re-implementing canOutsideClickClose but it's just dead simple
fixes #1313
@llorca
Copy link
Contributor Author

llorca commented Aug 10, 2017

4e5e9c9 🏆 🥇

@blueprint-bot
Copy link

replace pointer-events with user-select on dialog to support container scrolling

Preview: documentation
Coverage: core | datetime

@blueprint-bot
Copy link

add .pt-dialog-container to markup example, remove custom docs section style

Preview: documentation
Coverage: core | datetime


private handleContainerClick = (evt: React.MouseEvent<HTMLDivElement>) => {
// quick re-implementation of canOutsideClickClose because .pt-dialog-container covers the backdrop
if (this.props.canOutsideClickClose && evt.currentTarget.closest(`.${Classes.DIALOG}`) == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the second part of the boolean condition here will always be true because currentTarget is .pt-dialog-container... I think you want evt.target instead

Copy link
Contributor

@giladgray giladgray Aug 10, 2017

Choose a reason for hiding this comment

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

currentTarget should be container. i'm testing that the click did not come from within the .pt-dialog, meaning it came from the .pt-dialog-container itself.

you're completely right, i blew it ❌

@blueprint-bot
Copy link

fix isClickOutsideDialog logic

Preview: documentation
Coverage: core | datetime

Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

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

why mousedown instead of click?

also you have a merge conflict

@giladgray
Copy link
Contributor

it's always been mousedown for "outside click." there was an old bug with click where you could move the mouse around while holding it down and do weird things.

@llorca
Copy link
Contributor Author

llorca commented Aug 10, 2017

@adidahiya the real backdrop in Overlay uses onMouseDown so we're just replicating https://github.com/palantir/blueprint/blob/master/packages/core/src/components/overlay/overlay.tsx#L239

@blueprint-bot
Copy link

Merge branch 'master' into al/dialog-flex

Preview: documentation
Coverage: core | datetime

// LEGACY: override old (<= 1.24.0) dialog styles when inside a container to respect flex layout
.pt-dialog {
// stylelint-disable-next-line declaration-no-important
position: static !important;

Choose a reason for hiding this comment

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

Hey can this be reasonably removed? This is some pretty wicked styling to overcome if you don't want your dialog to be in the center of the screen.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kmwhelan93 please file a new issue to discuss this. nearly lost this comment to the sands of time. also note that we're working on 3.0 on develop, while this PR is way back in the 1.x days.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kmwhelan93 or even better, hit me with a PR and a passing build! ✅

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.

6 participants