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

Scrollable modal #27769

Merged
merged 6 commits into from
Jan 20, 2019
Merged

Scrollable modal #27769

merged 6 commits into from
Jan 20, 2019

Conversation

ysds
Copy link
Member

@ysds ysds commented Dec 5, 2018

This feature is inspired by MDC Dialog.

The scrollable modal allows scrolling the modal body. The standard model height fits to own content height, but the scrollable modal fits within the viewport height if the content is too long.

image

demo: https://deploy-preview-27769--twbs-bootstrap4.netlify.com/docs/4.2/components/modal/#scrolling-long-content

Cheers!

@ysds ysds requested review from a team as code owners December 5, 2018 02:11
js/src/modal.js Show resolved Hide resolved
scss/_modal.scss Outdated Show resolved Hide resolved
scss/_modal.scss Outdated Show resolved Hide resolved
scss/_modal.scss Outdated Show resolved Hide resolved
Copy link
Member

@Johann-S Johann-S left a comment

Choose a reason for hiding this comment

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

Can you add a unit test please ?
Otherwise LGTM 👍

@ysds
Copy link
Member Author

ysds commented Dec 6, 2018

I'm not very familiar with QUnit. I'd like to ask your support 🙏

@Johann-S
Copy link
Member

Johann-S commented Dec 6, 2018

@ysds you have to check when you a modal is shown, if this modal has .modal-dialog-scrollable class, the modal body scrollTop property should be equal to 0

@ysds ysds force-pushed the scrollable-modal branch from 42330be to 6b81006 Compare December 6, 2018 15:02
@MartijnCuppens
Copy link
Member

@ysds, you'll need to add a test to this file: https://github.com/twbs/bootstrap/blob/v4-dev/js/tests/unit/modal.js
The scenario Johann describes should be a good test. I think you'll find out how the tests work if you look at other tests, but if encounter problems with it, let us know.

@tmorehouse
Copy link
Contributor

I wonder if the scrollable content should be default behaviour on vertically centered modals?

@ysds
Copy link
Member Author

ysds commented Dec 14, 2018

@Johann-S I think that test result will always be OK, because the initial scrollTop of a modal body is 0. After creating a modal that overflows the height of the viewport, then it is necessary to change the scroll potion. How can I define a modal that overflows the height of the viewport? What is the height of the viewport in the test?

(I have never written a Qunit test script)

@Johann-S
Copy link
Member

@ysds it seems not see: https://coveralls.io/builds/20490418/source?filename=js/src/modal.js#L251
If it was the case this line would be covered.

You have to create a modal with a height greater than window.outerHeight to overflow the height of the viewport.
A QUnit test or a unit test in a DOM, is the same as writting JS, you have to create the HTML a be sure your logic works

@ysds
Copy link
Member Author

ysds commented Dec 14, 2018

Done. I had some misunderstanding. It seems there was no need to get the viewport height.

MartijnCuppens
MartijnCuppens previously approved these changes Dec 19, 2018
Copy link
Member

@MartijnCuppens MartijnCuppens left a comment

Choose a reason for hiding this comment

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

The css LGTM

Copy link
Member

@Johann-S Johann-S left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@XhmikosR
Copy link
Member

Rebased.

scss/_modal.scss Outdated Show resolved Hide resolved
@XhmikosR
Copy link
Member

XhmikosR commented Jan 9, 2019

@mdo: Is there something else we need here or can we merge?

@ysds
Copy link
Member Author

ysds commented Jan 9, 2019

Please wait to merge! I found a better workaround for the strange scrollbar behavior on IE.

@ysds ysds force-pushed the scrollable-modal branch from a289559 to cfb45ac Compare January 9, 2019 14:13
@ysds
Copy link
Member Author

ysds commented Jan 9, 2019

I changed the modal.css only and force-pushed. Sorry but please review again 🙏

@MartijnCuppens MartijnCuppens dismissed their stale review January 11, 2019 12:45

Latest changes not reviewed yet

Copy link
Member

@mdo mdo left a comment

Choose a reason for hiding this comment

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

Excited for this! Thank you <3.

@mdo mdo mentioned this pull request Jan 20, 2019
@XhmikosR XhmikosR merged commit de0bb1e into twbs:v4-dev Jan 20, 2019
@ysds ysds deleted the scrollable-modal branch March 12, 2019 03:25
benouat pushed a commit to ng-bootstrap/ng-bootstrap that referenced this pull request Jun 24, 2019
Introduces the new modal feature behind twbs/bootstrap#27769.
Setting the option `scrollable: true` will add the corresponding bootstrap class `.modal-dialog-scrollable`
mijohnsmith pushed a commit to mijohnsmith/ng-bootstrap that referenced this pull request Jun 27, 2019
Introduces the new modal feature behind twbs/bootstrap#27769.
Setting the option `scrollable: true` will add the corresponding bootstrap class `.modal-dialog-scrollable`
lupinthethirdgentleman pushed a commit to lupinthethirdgentleman/angular-bootstrap that referenced this pull request Aug 5, 2021
Introduces the new modal feature behind twbs/bootstrap#27769.
Setting the option `scrollable: true` will add the corresponding bootstrap class `.modal-dialog-scrollable`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants