Skip to content

fix alignment of switches positioned absolutely#3812

Merged
bramkragten merged 3 commits into
home-assistant:devfrom
iantrich:absolute-switches
Sep 30, 2019
Merged

fix alignment of switches positioned absolutely#3812
bramkragten merged 3 commits into
home-assistant:devfrom
iantrich:absolute-switches

Conversation

@iantrich
Copy link
Copy Markdown
Member

closes #3810

@iantrich iantrich self-assigned this Sep 26, 2019
@balloob
Copy link
Copy Markdown
Member

balloob commented Sep 26, 2019

Although this fixes it, I rather have us figure out how position: relative is set as an inline style.

@iantrich
Copy link
Copy Markdown
Member Author

I couldn't figure that out

@bramkragten
Copy link
Copy Markdown
Member

It is the ripple directive:
https://github.com/material-components/material-components-web-components/blob/b1d1640c9c3b27ec0f3c9054c1b2a158f23a891a/packages/ripple/src/ripple-directive.ts#L79

You can prevent it by putting the position inline, saves an override with !important

@bramkragten
Copy link
Copy Markdown
Member

Seems like the google and alexa entities pages are also affected with some styling issues

@balloob
Copy link
Copy Markdown
Member

balloob commented Sep 26, 2019

I think the easier trick is to just wrap the switches in a div, position absolute the div. Overriding the position means the ripple will not work.

@bramkragten
Copy link
Copy Markdown
Member

I tried it, and the ripple seemed to work fine, this behavior has changed in a recent update of mwc-switch, not sure if it is intended or not, seems a bit weird

@balloob
Copy link
Copy Markdown
Member

balloob commented Sep 26, 2019

I still prefer to wrap it, if ripple expects position: relative, we should not mess with it.

@iantrich
Copy link
Copy Markdown
Member Author

So I would make my own render with the outside div and pass all properties to the inner mwc-switch?

@bramkragten
Copy link
Copy Markdown
Member

No, you just add a div to the switches that are absolute positioned now:

<div class="position-absolute-class">
    <ha-switch></ha-switch>
</div>

@bramkragten bramkragten merged commit 64366dc into home-assistant:dev Sep 30, 2019
@bramkragten
Copy link
Copy Markdown
Member

We also have to look at the google and alexa entities pages:

image

@iantrich
Copy link
Copy Markdown
Member Author

I think that's present anywhere there is text after the switch, like editors as well...

@iantrich iantrich deleted the absolute-switches branch September 30, 2019 19:53
@bramkragten
Copy link
Copy Markdown
Member

OK, so it does have a slot, but no styling? I guess we have to add some styling to the slot.

@bramkragten bramkragten mentioned this pull request Oct 2, 2019
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switches gone bad

4 participants