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

adding some composition options for modals #15084

Merged
merged 4 commits into from
Dec 5, 2022
Merged

Conversation

selfcontained
Copy link
Contributor

@selfcontained selfcontained commented Nov 30, 2022

Description

The intention here is to fix the linked issue below so modals are more responsive, and the body of a modal can shrink and scroll when needed. To accomplish that, I needed to add a few css classes to the modal container and body wrapper. In order to allow us to have these sections of a modal consistently rendered, I created a few sub-components so we can compose our Modals a bit as well. <Modal/>s can still use the title prop and buttons prop, which will get wrapped automatically like they were. It might be a good idea to unify how we render modals though at some point, and always compose them like below, but not an urgent change we have to make. These changes should provide a responsive modal w/ scrollable body for any pre-existing modal that was passing in a title prop as well.

I've also moved the classnames dependency from devDeps to normal deps as I wanted to use it for some conditional class names. I'm happy to adjust that back though if we explicitly don't want to use classnames outside of tests though.

<Modal ...>
  <ModalHeader ...>
  <ModalContent ...>
  <ModalFooter ...>
</Modal>

We can iterate on this, and add built-in behavior to support pinned error messages on a modal that I saw in at least one place (when adding a new integration). This would allow that style of modal to also render responsively for smaller screen sizes.

Related Issue(s)

Fixes #12899, #10747

How to test

Navigate to Settings/Integrations and edit one of the integrations to open the modal.

  • Resize your browser window to be smaller than the height of the modal, and you should see it shrink, while being able to scroll the inner contents of the modal.

image

* I've applied the same updates to the Environment Variables modal.

Release Notes

Fixes an issue with modals not displaying properly on smaller screens.

Documentation

Werft options:

  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-bmh-scrollable-modal-content.2 because the annotations in the pull request description changed
(with .werft/ from main)

@@ -14,8 +15,8 @@ export default function Modal(props: {
specify?: string;
title?: string;
hideDivider?: boolean;
buttons?: React.ReactChild[] | React.ReactChild;
children: React.ReactChild[] | React.ReactChild;
buttons?: ReactNode;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ReactNode type encompasses arrays or single children, but also allows for null.

(props.className || "")
}
className={cn(
"flex flex-col max-h-screen relative bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-xl p-6 max-w-lg mx-auto text-left ",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this allows the modal container to adjust height, while being height constrained to the screen viewport

@roboquat roboquat added size/M and removed size/L labels Dec 2, 2022
@selfcontained selfcontained marked this pull request as ready for review December 2, 2022 00:11
@selfcontained selfcontained requested a review from a team December 2, 2022 00:11
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Dec 2, 2022
@easyCZ
Copy link
Member

easyCZ commented Dec 2, 2022

When testing with Brave, on a 4k screen, the modal renders what looks like scroll bars, without actually being scrollable.

Screenshot 2022-12-02 at 16 36 12

Screenshot 2022-12-02 at 16 35 41

@gtsiolis gtsiolis self-requested a review December 2, 2022 17:09
@selfcontained
Copy link
Contributor Author

Good catch - I think this is from not using an overflow: auto style (browsers should hide scrollbars unless needed). I'ved updated that scrollable body to use a tailwind class that should remove the scrollbars unless needed (also it should only apply a vertical scrollbar if needed and no horizontal).

@easyCZ
Copy link
Member

easyCZ commented Dec 5, 2022

Screenshot 2022-12-05 at 10 07 50

Looking good. Fixes the problem of not being able to scroll the modal.

Copy link
Member

@easyCZ easyCZ left a comment

Choose a reason for hiding this comment

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

LGTM

@gtsiolis
Copy link
Contributor

gtsiolis commented Dec 5, 2022

Looking at this now! 👀

Copy link
Contributor

@gtsiolis gtsiolis left a comment

Choose a reason for hiding this comment

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

Hey @selfcontained! Welcome to the team, and thanks for opening this! ✨

Left a few non-blocking comments below that we can split into separate follow-up issues.

Some thoughts on the UX changes of this PR:

  1. The responsive design of the dashboard is being tracked in Epic: Improve dashboard responsive layout #4050. 💡
  2. Improvements like creating more flexible and compact components like Replace the editor selection cards with the new dropdown component used in the start with options new workspace modal #13116 could help in some cases, see early designs in IDE selection modal window not fiting in screen #10747 (comment). 💡
  3. Generally, we could aim for making the viewport scrollable when the modal content extends below the viewport. 💭
  4. But making the modal contents scroll here sounds like a good, boring (simple) MVC solution here and will also resolve issues like IDE selection modal window not fiting in screen #10747. 🛹
  5. If scrolling is needed, this may be a good indicator to consider opening the content in a new page instead. So far, the modal component and pattern has suited well our needs, and we just started experimenting with opening content in new pages in the new access tokens product are, see /new and /edit flows in /tokens. 💡

Since code changes have been approved from two WebApp team members and there are no blocking UX comments, let's take a bias for action, merge this, and open any follow-up issues if needed. ✔️

@@ -291,8 +291,8 @@ function GitProviders() {
{editModal && (
// TODO: Use title and buttons props
<Modal visible={true} onClose={() => setEditModal(undefined)}>
<h3 className="pb-2">Edit Permissions</h3>
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4">
<ModalHeader>Edit Permissions</ModalHeader>
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Since you've replaced the modal contents here could we also replace the contents for the New Git integration modal which is also much needed, see L750 below. If this is not as straightforward as the other instances, let's open a follow-up to keep track of this. 🏓

<h3 className="pb-2">{mode === "new" ? "New Git Integration" : "Git Integration"}</h3>

(props.className || "")
}
className={cn(
"flex flex-col max-h-screen relative bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-xl p-6 max-w-lg mx-auto text-left ",
Copy link
Contributor

Choose a reason for hiding this comment

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

thought: This will also resolve #10747. I've updated the PR description to also include that issue.

Comment on lines +97 to +99
<ModalHeader>{props.title}</ModalHeader>
<ModalBody hideDivider={props.hideDivider}>{props.children}</ModalBody>
<ModalFooter>{props.buttons}</ModalFooter>
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: Not sure if this introduces unnecessary complexity, but more structure like this is definitely needed! ✨

</div>
<div className="flex justify-end mt-6 space-x-2">{props.buttons}</div>
<ModalHeader>{props.title}</ModalHeader>
<ModalBody hideDivider={props.hideDivider}>{props.children}</ModalBody>
Copy link
Contributor

Choose a reason for hiding this comment

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

fyi: Not sure where to add this comment, but one modal I'd love to improve after thes changes is the feedback modal. Cross-posting follow up issue (#10307) for visibility.

@gtsiolis
Copy link
Contributor

gtsiolis commented Dec 5, 2022

/unhold

@roboquat roboquat merged commit 80a1a4f into main Dec 5, 2022
@roboquat roboquat deleted the bmh/scrollable-modal-content branch December 5, 2022 13:43
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Dec 6, 2022
@gtsiolis gtsiolis mentioned this pull request Mar 16, 2023
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note size/M team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Edit permission not showing save button and not scrollale on 14inch laptop
5 participants