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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/core/src/components/drawer/drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,16 @@ export class Drawer extends AbstractPureComponent<DrawerProps> {
};

public render() {
const { size, style, position } = this.props;
const { hasBackdrop, size, style, position } = this.props;
const { className, children, ...overlayProps } = this.props;
const realPosition = getPositionIgnoreAngles(position!);

const classes = classNames(
Classes.DRAWER,
{
[Classes.positionClass(realPosition) ?? ""]: true,
},
this.props.className,
className,
);

const styleProp =
Expand All @@ -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.

<div className={classes} style={styleProp}>
{this.maybeRenderHeader()}
{this.props.children}
{children}
</div>
</Overlay>
);
Expand Down
3 changes: 2 additions & 1 deletion packages/docs-app/src/styles/_examples.scss
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,8 @@ $docs-hotkey-piano-height: 510px;
}

#{example("ButtonGroup")},
#{example("ButtonGroupPopover")} {
#{example("ButtonGroupPopover")},
#{example("Drawer")} {
.docs-example > * {
margin: 0;
Comment on lines +591 to 593
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

}
Expand Down