-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Feat: MdDialog to target specific element with md-target attr #2254
base: dev
Are you sure you want to change the base?
Conversation
…-material into dialogs-target-el # Conflicts: # dist/components/MdDatepicker/index.css # dist/components/MdDatepicker/index.js # dist/components/MdDialog/index.css # dist/components/MdDialog/index.js # dist/components/MdDrawer/index.js # dist/components/index.css # dist/components/index.js # dist/vue-material.css # dist/vue-material.js # dist/vue-material.min.css # dist/vue-material.min.js
{ | ||
name: "md-target", | ||
type: "HTMLElement", | ||
description: | ||
"The dialog will be attached inside of the specificied HTML element instead of the body tag. The HTMLElement needs to have position relative CSS property.", | ||
defaults: "null", | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just added this
@@ -1,13 +1,24 @@ | |||
<template> | |||
<md-portal> | |||
<md-portal :mdTarget="mdTarget"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added mdTarget
:mdTarget="mdTarget" | ||
:md-fixed=" mdTarget ? false : true " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added mdTarget prop and md-fixed if mdTarget
<transition name="md-dialog"> | ||
<div class="md-dialog" v-if="mdActive"> | ||
<div class="md-dialog" :class=" mdTarget ? 'with-target' : '' " v-if="mdActive"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add with-target class in case of mdTarget
mdTarget: { | ||
type: null, | ||
default: null, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added mdTarget prop
if (this.mdTarget) { | ||
if (isActive) { | ||
this.mdTarget.style.overflow = "hidden"; | ||
} else { | ||
this.mdTarget.style.overflow = "auto"; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forcing overflow behavioiur on target element if present to set the overlay fixed
&.with-target { | ||
position: absolute; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added with-target css rule to bypass fixed position not able to target elements
@@ -19,7 +19,9 @@ export default { | |||
display: flex; | |||
align-items: center; | |||
justify-content: flex-end; | |||
position: relative; | |||
position: relative; | |||
backface-visibility: hidden; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it fix hidden btn texts on chrome
@@ -1,58 +1,62 @@ | |||
<template> | |||
<md-portal :md-attach-to-parent="mdAttachToParent"> | |||
<md-portal :md-attach-to-parent="mdAttachToParent" :mdTarget="mdTarget"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added mdTarget to mdPortal in mdOverlay
mdTarget: { | ||
type: null, | ||
default: null, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added mdTarget prop
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