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

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

Open
wants to merge 19 commits into
base: dev
Choose a base branch
from

Conversation

mikimoresi
Copy link
Contributor

@mikimoresi mikimoresi commented Aug 12, 2020

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

Michele Moresi and others added 11 commits August 14, 2020 10:32
…-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
@mikimoresi mikimoresi changed the title MdDialog to target specific element Feat: MdDialog to target specific element with md-target attr Aug 14, 2020
Comment on lines +117 to +123
{
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",
},
Copy link
Contributor Author

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">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added mdTarget

Comment on lines +16 to +17
:mdTarget="mdTarget"
:md-fixed=" mdTarget ? false : true "
Copy link
Contributor Author

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">
Copy link
Contributor Author

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

Comment on lines +45 to +48
mdTarget: {
type: null,
default: null,
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added mdTarget prop

Comment on lines +85 to +91
if (this.mdTarget) {
if (isActive) {
this.mdTarget.style.overflow = "hidden";
} else {
this.mdTarget.style.overflow = "auto";
}
}
Copy link
Contributor Author

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

Comment on lines +145 to +147
&.with-target {
position: absolute;
}
Copy link
Contributor Author

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;
Copy link
Contributor Author

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">
Copy link
Contributor Author

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

Comment on lines +18 to +21
mdTarget: {
type: null,
default: null,
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added mdTarget prop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
v1.0.0
To do
Development

Successfully merging this pull request may close these issues.

None yet

2 participants