Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Modal: add verticalScrollMode property to limit overflow to children #206

Merged
merged 1 commit into from
Jul 20, 2020

Conversation

timbotnik
Copy link
Contributor

In some cases we want to be able to see the action buttons even if the child content overflows - this gives us a way to use a flex column layout and move the overflow-y to the div that wraps children.

@timbotnik timbotnik force-pushed the timbotnik/modal-overflow-children branch from 458a968 to 8e85d31 Compare July 17, 2020 03:37
@timbotnik timbotnik force-pushed the timbotnik/modal-overflow-children branch from 8e85d31 to 5859489 Compare July 17, 2020 03:42
@timbotnik timbotnik added the minor Increment the minor version when merged label Jul 17, 2020
Copy link
Member

@cheapsteak cheapsteak left a comment

Choose a reason for hiding this comment

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

Is there a way to solve this by adding a less specific prop? (maybe expose classNames on the div that wraps the "actions"?)

Aside from the concern for option-bloat, verticalScrollMode="children" is a sequence of words that I might have trouble making a reasonable guess at what it does if I saw them at a usage site

It's also adding a flag argument / code smell that imo indicates the component might not be optimally factored; For comparison, the Modal components of material-ui, fluent-ui, semantic-ui, and chakra-ui do not make assumptions about the contents of a Modal the way we do (imo this is presently an overly-specific lego piece, although out of this PR's scope to solve)

I'm not sure how to balance "wanting a great api for a shared public ui lib" and "not wanting to block sprint work in the main project the lib is used for". Going to punt that question to other reviewers 🙈

@cheapsteak cheapsteak requested a review from a team July 17, 2020 18:31
@timbotnik
Copy link
Contributor Author

timbotnik commented Jul 19, 2020

Thx for the insightful review @cheapsteak. I agree with you on most of these points.

Is there a way to solve this by adding a less specific prop? (maybe expose classNames on the div that wraps the "actions"?)

I would have liked this as well, but it seemed like I needed to do these 3 things:

  1. turn off overflow-y: auto on the parent div so that we'd be able to handle the overflow in descendants
  2. make the layout display: flex; flex-direction: column so we could stretch the children area to fill the modal
  3. set overflow-y: auto on the div that wraps children.

I think there is a slight alternative here where we could pass in classNames to get #1 & #2 and expose a childWrapperClassnames property for #3. It did feel pretty weird to me that we'd be passing in a flex layout which would depend on the nesting of things inside the modal to stay the same so I didn't pursue that option. It felt like this component had already made a call to be more of a layout owner, and this could certainly lead to options creep if we keep going this way.

I think ultimately what we might want is a way to separate a Modal (which handles the basic treatment of popping up a card) and the internal Modal layout as different things, allowing us to have different modal layouts or potentially fully customize the layout at usage site.

Aside from the concern for option-bloat, verticalScrollMode="children" is a sequence of words that I might have trouble making a reasonable guess at what it does if I saw them at a usage site

I toyed around with different names here like overflowYAt: 'children' | 'modal', but yeah not really the main problem here.

I'm not sure how to balance "wanting a great api for a shared public ui lib" and "not wanting to block sprint work in the main project the lib is used for". Going to punt that question to other reviewers 🙈

Based on time we need to ship something now and revisit it.

Copy link
Member

@cheapsteak cheapsteak left a comment

Choose a reason for hiding this comment

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

Appreciate your patience in walking through the options considered 🙏

It felt like this component had already made a call to be more of a layout owner

First time hearing the term "layout owner", that's exactly it ⚡
The outward-facing option bloat is one part, the additional internal branching is another, both are a bit of a bummer

You're right though that this component has already decided to own layout and there doesn't seem to be a good way to invert control to usage sites without also requiring the user to read this component's internals

I think ultimately what we might want is a way to separate a Modal (which handles the basic treatment of popping up a card) and the internal Modal layout as different things, allowing us to have different modal layouts or potentially fully customize the layout at usage site.

Agreed. IMO Chakra/Semantic handle this wonderfully -- Modal is just the popup treatment, anything can be passed in as children, but they also provide ModalHeader/Modal.Header, ModalBody/Modal.Content etc helper components with preset styles.

Based on time we need to ship something now and revisit it.

👍 :shipit:

@timbotnik
Copy link
Contributor Author

Merging but let's get this refactor on the agenda at some point.

@timbotnik timbotnik merged commit 765a60e into master Jul 20, 2020
@timbotnik timbotnik deleted the timbotnik/modal-overflow-children branch July 20, 2020 12:18
@apollo-bot2
Copy link
Collaborator

🚀 PR was released in v7.6.0 🚀

@apollo-bot2 apollo-bot2 added the released This issue/pull request has been released. label Jul 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
minor Increment the minor version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants