Skip to content

playground for auto sized sheets #2793

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

Closed
3 tasks done
DavidStrausz opened this issue Feb 25, 2023 · 7 comments · Fixed by #2905
Closed
3 tasks done

playground for auto sized sheets #2793

DavidStrausz opened this issue Feb 25, 2023 · 7 comments · Fixed by #2905
Labels
content Issues related to the contents of the documentation website feature request Feature requests for the documentation website

Comments

@DavidStrausz
Copy link

DavidStrausz commented Feb 25, 2023

Prerequisites

Describe the Feature Request

Sheet modals that are sized according to their content. If the content exceeds the max-height, I would expect it to be scrollable. If the height of the content changes, the sheet modal should also change its height accordingly. Changing breakpoints is not possible, swiping down dismisses the sheet. It would also be nice if the height of the keyboard could be accounted for, if it is open (or just expand to max-height).

Describe the Use Case

We find ourselves more and more in situations where an auto-height sheet modal would come in very handy. For example we recently added a new payment flow in our app which makes use of different sheets for e.g. showing payment status, entering payment details, and in a lot of these cases we just wanted the sheet modal to be the size of its content. This is currently hard to do when considering different screen sizes on different devices.

A B
Xnapper-2023-02-25-20 28 02 Xnapper-2023-02-25-20 29 25

A lot of native sheets behave that way too:

Twitter A Twitter B Twitter C
Xnapper-2023-02-25-20 22 10 Xnapper-2023-02-25-20 20 25 Xnapper-2023-02-25-20 23 41
Apple Maps A Apple Maps B
Xnapper-2023-02-25-21 57 30 Xnapper-2023-02-25-21 57 51

Describe Preferred Solution

Setting initialBreakpoint to auto could be an possible option to control the feature. Setting the breakpoints array would not have any effect if initialBreakpoint is set to auto.

Describe Alternatives

We tried to do it with custom css but it broke the sheets enter animation. Also, it would just be nice if it would be supported out of the box :)

ion-modal.auto-height {
  --height: auto;
  --max-height: 90vh;

  div.content-wrapper {
    overflow-y: scroll;
  }
}

Related Code

No response

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage New issues label Feb 25, 2023
@liamdebeasi liamdebeasi self-assigned this Feb 27, 2023
@liamdebeasi
Copy link
Contributor

liamdebeasi commented Feb 27, 2023

Thanks for the report. The requested behavior should already be available in Ionic Framework. In this case, you will want to use --height: fit-content and avoid the use of ion-content. The reason is ion-content is sized relative to the content around it, so having an automatic height will cause the ion-content to have a height of 0px.

Here is a demo: https://codepen.io/liamdebeasi/pen/WNgogJp

This feature is referred to as Custom Dialogs and is useful when you want a modal that is not full page. Can you give this a try and let me know if it works?

@liamdebeasi liamdebeasi added the needs: reply Issues that need more information from the author label Feb 27, 2023
@ionitron-bot ionitron-bot bot removed the triage New issues label Feb 27, 2023
@liamdebeasi liamdebeasi removed their assignment Feb 27, 2023
@DavidStrausz
Copy link
Author

@liamdebeasi Thank you for your response :)
Setting --height to fit-content works perfectly in Chromium based browsers, but in Webkit browsers this makes the sheet disappear entirely (happens in your demo too).

@ionitron-bot ionitron-bot bot added triage New issues and removed needs: reply Issues that need more information from the author labels Feb 27, 2023
@liamdebeasi
Copy link
Contributor

Whoops! You can probably stick with auto actually. That seems to work fine in Chrome and Safari.

@liamdebeasi liamdebeasi added the needs: reply Issues that need more information from the author label Feb 27, 2023
@ionitron-bot ionitron-bot bot removed the triage New issues label Feb 27, 2023
@DavidStrausz
Copy link
Author

@liamdebeasi Thanks! Setting it to auto works :) When I last tried that, I somehow managed to mess up the enter animation of the sheet, but can't reproduce it anymore.

I think a short "receipe" for auto height sheets in the docs would be useful for others, who try to do the same.

@ionitron-bot ionitron-bot bot added triage New issues and removed needs: reply Issues that need more information from the author labels Feb 27, 2023
@liamdebeasi
Copy link
Contributor

liamdebeasi commented Feb 27, 2023

We already have a recipe for this: https://ionicframework.com/docs/api/modal#custom-dialogs

This particular demo is using fit-content, but the same concepts apply.

edit: Misread that, yes we should have a recipe specifically for sheets.

@liamdebeasi liamdebeasi added the needs: reply Issues that need more information from the author label Feb 27, 2023
@ionitron-bot ionitron-bot bot removed the triage New issues label Feb 27, 2023
@liamdebeasi
Copy link
Contributor

Going to move this to the docs repo so we can track the documentation updates.

@ionitron-bot ionitron-bot bot added triage New issues and removed needs: reply Issues that need more information from the author labels Feb 27, 2023
@liamdebeasi liamdebeasi transferred this issue from ionic-team/ionic-framework Feb 27, 2023
@liamdebeasi liamdebeasi changed the title feat: auto-height sheet modals playground for auto sized sheets Feb 27, 2023
@liamdebeasi liamdebeasi added content Issues related to the contents of the documentation website feature request Feature requests for the documentation website labels Feb 27, 2023
@ionitron-bot ionitron-bot bot removed the triage New issues label Feb 27, 2023
@thetaPC
Copy link
Contributor

thetaPC commented Apr 12, 2023

Thanks for the issue! The playground was added via #2905 and will be available soon at the modal page.

@ionic-team ionic-team locked as resolved and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
content Issues related to the contents of the documentation website feature request Feature requests for the documentation website
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants