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

[core] fix(Drawer): allow clicking on overlaid contents when hasBackdrop=false #6650

Merged
merged 2 commits into from
Jan 12, 2024

Conversation

joncelay
Copy link
Contributor

Fixes #3515

Checklist

  • Includes tests (n/a)
  • Update documentation (n/a)

Changes proposed in this pull request:

Remove the modal trait of Drawer when hasBackdrop is set to false
by making overlay container styles conditional to hasBackdrop.

Reviewers should focus on:

  • Verify the behavior with and without portal
  • Verify the scrolling of Drawer content on smaller screen size
  • Note that canOutsideClickClose becomes ignore when hasBackdrop is false

Screenshot

New: clicking outside the drawer discards it and changes the position selection
drawer-backdrop

Old: clicking outside the drawer discards it. An additional click is required to change the position selection
drawer-backdrop-old

Comment on lines +591 to 593
#{example("Drawer")} {
.docs-example > * {
margin: 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing the margin to prevent the button from jumping:
drawer-margin

@joncelay joncelay marked this pull request as draft January 11, 2024 20:06
@adidahiya
Copy link
Contributor

extract className from props

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@joncelay joncelay marked this pull request as ready for review January 11, 2024 22:57
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.

This seems to work well and it is a good improvement over the default. It is a behavior change compared to the current <Drawer hasBackdrop={false}> (which can sometimes be considered breaking), but I think it will be a welcome one. Users are already able to scroll the contents behind a drawer when hasBackdrop={false}:

Screen Recording 2024-01-12 at 9 43 47 AM

this just makes it so that they can also click on the content underneath, as you demonstrated above 👍

@@ -130,10 +131,10 @@ export class Drawer extends AbstractPureComponent<DrawerProps> {
[isPositionHorizontal(realPosition) ? "height" : "width"]: size,
};
return (
<Overlay {...this.props} className={Classes.OVERLAY_CONTAINER}>
<Overlay {...overlayProps} className={classNames({ [Classes.OVERLAY_CONTAINER]: hasBackdrop })}>
Copy link
Contributor

Choose a reason for hiding this comment

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

I realize now that this "overlay container" class (added in #2957) has a somewhat misleading name since it's only used by the Drawer component and it's non-descriptive about its purpose... it might make more sense to call this "OVERLAY_FIXED_BACKDROP" or something like that. We can't change it now though; it's part of the public API... just musing about the name here, perhaps I'll add some code comments about this in a separate PR.

@adidahiya adidahiya changed the title [core] fix(Drawer): include overlay-container classes only when there is a backdrop [core] fix(Drawer): allow clicking on overlaid contents when hasBackdrop=false Jan 12, 2024
@adidahiya adidahiya merged commit c89bb74 into develop Jan 12, 2024
12 checks passed
@adidahiya adidahiya deleted the jo/drawer-backdrop branch January 12, 2024 14:46
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.

Feature Request: Drawer option to not render overlay
2 participants