Skip to content
Closed
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
2 changes: 2 additions & 0 deletions UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

### Bug fixes

- Constrained `DropZone` height based on inherited wrapper height ([#2846](https://github.com/Shopify/polaris-react/pull/2846))

### Documentation

### Development workflow
Expand Down
11 changes: 11 additions & 0 deletions src/components/DropZone/DropZone.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,19 @@ $dropzone-stacking-order: (
border: border-width(thick) $dropzone-border-style transparent;
}

.DropZoneWrapper {
height: 100%;

> div {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is always a bit risky to do, because if the Labelled wrapping markup changes we need to make sure that this will change as well. I think thanks to the splash build tooling that polaris uses, we will get a notification that at least indicates DropZone will be affected by Labelled changes. Still... I'm wondering if we should qualify this with a comment to express why we need to override some Labelled styles?

Copy link
Member

Choose a reason for hiding this comment

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

Probably a comment or it'll be forgotten about and list in the 💨

height: 100%;
display: flex;
flex-direction: column;
}
}

.DropZone {
position: relative;
flex: 1;
display: flex;
justify-content: center;
background-color: $dropzone-background;
Expand Down
50 changes: 26 additions & 24 deletions src/components/DropZone/DropZone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -378,31 +378,33 @@ export const DropZone: React.FunctionComponent<DropZoneProps> & {

return (
<DropZoneContext.Provider value={context}>
<Labelled
id={id}
label={labelValue}
action={labelAction}
labelHidden={labelHiddenValue}
>
<div
ref={node}
className={classes}
aria-disabled={disabled}
onClick={handleClick}
onDragStart={stopEvent}
<div className={styles.DropZoneWrapper}>
<Labelled
id={id}
label={labelValue}
action={labelAction}
labelHidden={labelHiddenValue}
>
{dragOverlay}
{dragErrorOverlay}
<div className={styles.Container}>{children}</div>
<VisuallyHidden>
<DropZoneInput
{...inputAttributes}
openFileDialog={openFileDialog}
onFileDialogClose={onFileDialogClose}
/>
</VisuallyHidden>
</div>
</Labelled>
<div
ref={node}
className={classes}
aria-disabled={disabled}
onClick={handleClick}
onDragStart={stopEvent}
>
{dragOverlay}
{dragErrorOverlay}
<div className={styles.Container}>{children}</div>
<VisuallyHidden>
<DropZoneInput
{...inputAttributes}
openFileDialog={openFileDialog}
onFileDialogClose={onFileDialogClose}
/>
</VisuallyHidden>
</div>
</Labelled>
</div>
</DropZoneContext.Provider>
);

Expand Down
2 changes: 1 addition & 1 deletion src/components/DropZone/tests/DropZone.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ function fireEvent({

element
.find('div')
.at(3)
.at(4)
.getDOMNode()
.dispatchEvent(event);

Expand Down