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

Support configuring "root element" for modal #33018

Closed
wants to merge 7 commits into from

Conversation

spicalous
Copy link
Contributor

@spicalous spicalous commented Feb 8, 2021

Hi guys,

New contributor here, please let me know if I have missed anything

This PR attempts to resolve #31509 adding support to allow configuring the "root element" for the modal component. This PR only implements configuring this when initialising the modal via Javascript. I haven't dug deep into how this can be done via providing html attributes.

Please let me know if this is the right approach

Thanks!

preview

closes #34309

@spicalous spicalous requested a review from a team as a code owner February 8, 2021 23:45
@spicalous
Copy link
Contributor Author

Hi @XhmikosR is there something I can do to help move this PR along? :)

@XhmikosR
Copy link
Member

XhmikosR commented Mar 5, 2021

No, sorry, I'm a little busy with Real Life.

Maybe @rohit2sharma95 or @GeoSot can help with review.

For what is worth, I'm definitely in favor of the null tests change.

@GeoSot
Copy link
Member

GeoSot commented Mar 5, 2021

@spicalous try to create a working optical example in site/content/docs/5.0/components/modal.md in order to check it here

(You may need to revert it later)

@spicalous spicalous requested a review from a team as a code owner March 5, 2021 21:56
@spicalous spicalous force-pushed the modal-root-element-config branch from 550c63c to ea21df6 Compare March 5, 2021 22:01
@spicalous
Copy link
Contributor Author

@XhmikosR I didn't mean to rush, thank you for your time and bringing relevant people to the discussion!

@GeoSot I have added an example, please let me know what you think
https://deploy-preview-33018--twbs-bootstrap.netlify.app/docs/5.0/components/modal/#configuring-root-element

@GeoSot
Copy link
Member

GeoSot commented Mar 6, 2021

I would suggest you to open another Pr with the null changes on tests

I am not sure if CLASS_NAME_OPEN_CUSTOM_ROOT is needed, at least yet. I understand the root element, but I don't know if its ok to restrict the modal in inside a box, But I am not the right guy to answer this

@spicalous
Copy link
Contributor Author

spicalous commented Mar 6, 2021

I have created #33288 separately for the tests changes

In the mean time, i'm happy to either decline this or wait until someone can make the decision whether this feature should be added :)

Thanks for your time everyone

@GeoSot
Copy link
Member

GeoSot commented Mar 9, 2021

I have created #33288 separately for the tests changes

Spicalous Please remove them from here :)

@GeoSot
Copy link
Member

GeoSot commented Apr 18, 2021

@spicalous I apologize for the delay. I had in mind this PR, and tried to make some steps, on backdrop, scrollbar and modal. Do you still want to close it?

@spicalous
Copy link
Contributor Author

Thanks @GeoSot, happy to re-open. Only just saw the mention from #33665 now.

I haven't looked at the changes, but I assume we'll be able to incorporate the solution into this PR? I'll have a look at understanding the changes and will update this branch accordingly

Please let me know if this is what you had in mind or if there's something I should do / can help out with :)

@GeoSot
Copy link
Member

GeoSot commented Apr 18, 2021

Scrollbar and backdrop functionality, have been decoupled to be used on offcanvas too,
Backdrop is ready to accept a rootElement, but for scrollbar, I just needed to do it step by step. So I want to try to make the first step on #33665. Please keep an eye on it.

@GeoSot
Copy link
Member

GeoSot commented Jun 6, 2021

@spicalous

I think we are in the right moment to continue this MR.
Are ok to continue your proposal?

@spicalous
Copy link
Contributor Author

@GeoSot Had another attempt with the latest master

https://deploy-preview-33018--twbs-bootstrap.netlify.app/docs/5.0/components/modal/#configuring-root-element

Notes

  • The css doesn't support configurable root elements out of the box... and css is not my strong suite - I think I will need some help to make it better as it feels like a hack at the moment or it will need some testing
  • .modal-open seems to be an unused class now? So I have removed it

@GeoSot
Copy link
Member

GeoSot commented Jun 22, 2021

.modal-open seems to be an unused class now? So I have removed it

bring back .modal-open as we keep it for compatibility reasons

The css doesn't support configurable root elements out of the box... and css is not my strong suite - I think I will need some help to make it better as it feels like a hack at the moment or it will need some testing

I 'll try to help you till there, and we will find a solution

Plus:

  • Try to replace the _isCustomRoot with a private method hasCustomRoot
  • try to resolve rootElement inside _getConfig (getElement(config.rootElement))
  • Scrollbar maybe will need something more, but not too much (leave it for the end 😉 )

@@ -1,4 +1,4 @@
import { Tooltip } from '../../../dist/js/bootstrap.esm.js'
import { Tooltip } from './../../../dist/js/bootstrap.esm.js'
Copy link
Contributor Author

@spicalous spicalous Jun 22, 2021

Choose a reason for hiding this comment

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

I had to add this, otherwise the tests was failing for me :/

@GeoSot
Copy link
Member

GeoSot commented Jun 22, 2021

Please, keep calm. I am here 😋

Do not mess with backdrop yet. I am trying to help merging #34149

Try to keep your changes to minimum

js/src/modal.js Outdated Show resolved Hide resolved
site/assets/js/application.js Outdated Show resolved Hide resolved
@GeoSot
Copy link
Member

GeoSot commented Jul 1, 2021

@spicalous any update on this?

@spicalous spicalous force-pushed the modal-root-element-config branch from e1eb294 to 0536f6c Compare July 3, 2021 17:44
@GeoSot GeoSot self-assigned this Jul 5, 2021
js/src/modal.js Outdated Show resolved Hide resolved
js/src/util/backdrop.js Outdated Show resolved Hide resolved
site/assets/js/application.js Outdated Show resolved Hide resolved
constructor() {
this._element = document.body
constructor(rootElement) {
this._element = rootElement || document.body
Copy link
Member

Choose a reason for hiding this comment

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

You miss some things here 😉

plus the proper tests

This MR will help you

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how I could add a test in modal (I see in the MR that we are asserting spied methods of ScrollBarHelper. Please let me know if you had something in mind. In the mean time, I have added a test for ScrollBarHelper

Copy link
Member

@GeoSot GeoSot Jul 7, 2021

Choose a reason for hiding this comment

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

@spicalous
I tried to fix it a bit and added the tests and functionality for scrollbar.
I am not very sure about scrollbar modifications, so you better take a second look

@GeoSot
Copy link
Member

GeoSot commented Jul 6, 2021

Nice job till here 👍 Getting closer

tip: check the preview. modal.js:l89 misses the proper initialization

@GeoSot GeoSot force-pushed the modal-root-element-config branch from c17aae6 to 9d1c7b3 Compare July 7, 2021 22:17
@GeoSot
Copy link
Member

GeoSot commented Jul 12, 2021

I found out a 'bug'

if you try to put some content inside the empty root element, it will over-float. Till here we are fine.
Although if you try open the modal inside the scrolled down root element, the absolute position, will be out of user eyes 😕

@GeoSot GeoSot mentioned this pull request Nov 22, 2021
2 tasks
@GeoSot
Copy link
Member

GeoSot commented Dec 6, 2021

I am closing this as stale.
@spicalous if you find time, you can reopen it

@GeoSot GeoSot closed this Dec 6, 2021
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.

cannot set modal backdrop root element Target for .modal-open
3 participants