vuematerial / vue-material

Vue.js Framework - ready-to-use Vue components with Material Design, free forever.
https://www.creative-tim.com/vuematerial
MIT License
9.88k stars 1.16k forks source link

Feat: MdDialog to target specific element with md-target attr #2254

Open mikimoresi opened 3 years ago

mikimoresi commented 3 years ago

Hello, I have modified MdOverlay and MdDialog to add mdTarget prop. In this way it is possible to make a dialog appear inside a specific element. Passing in mdTarget prop an HTML element, the dialog and the overlay will appear in the given element and will not overlay the entire window. Because of the position:fixed attribute that cannot target a specific element with position:relative, i have used position absolute both for MdDialog and MdOverlay in case of mdTarget exists. Plus, when mdTarget exists the overflow of the given element will be forced to "hidden" when dialog is active and go back in "auto" when dialog disappear. The element in mdTarget MUST have position:relative

If you accept the proposal and maybe the pull request I will work on allowing the dialog to be scrollable if too long and maybe using a class on the mdTarget element instead of forcing the overflow style, this way anybody will be able to use that class for disable scrolling and doing any other desired thing like the required position:relative, the problem with this is that i would use pure js functions to add and remove classes while maybe there is some better approach, I will accept any suggestion.

Is my first pull request ever on an open source project (shame on me) so I don't know exactly how contributions works. So please be patient if I'm doing something wrong

EDIT: sorry for 10 comments below, i commented code lines to help reviews I didn't know it would create e reply for any comment