Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

fix(mdButton): icon vertical alignment #8194

Closed
wants to merge 3 commits into from

Conversation

epelc
Copy link
Contributor

@epelc epelc commented Apr 24, 2016

I applied the display change to .md-button md-icon because regular buttons with icons and fab buttons also require this fix.

This fixes md-icon vertical alignment within md-button. Closes #8066

@epelc epelc changed the title Fix icon vertical alignment within md-button. Closes #8066 fix(mdButton): icon vertical alignment Apr 24, 2016
@ThomasBurleson
Copy link
Contributor

@devversion - can you review/test ?

@ThomasBurleson ThomasBurleson added needs: review This PR is waiting on review from the team in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs labels Apr 24, 2016
@ThomasBurleson ThomasBurleson added this to the 1.1.1 milestone Apr 24, 2016
@epelc
Copy link
Contributor Author

epelc commented Apr 24, 2016

See the notes on the issue for how to test it easily.

On Sunday, April 24, 2016, Thomas Burleson [email protected] wrote:

@devversion https:/DevVersion - can you review/test ?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#8194 (comment)

Best regards,
Ed Pelc
President

Website: freightchick.com
Phone: 941-735-4047

@@ -145,6 +145,11 @@ button.md-button::-moz-focus-inner {
&.ng-hide, &.ng-leave {
transition: none;
}

md-icon {
// Fixes icon vertical alignment.
Copy link
Member

Choose a reason for hiding this comment

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

I think this comment is actually not saying really much.

Can we explain more, why this is needed and for example, which components are affected by the vertical alignment problem?

Copy link
Contributor Author

@epelc epelc Apr 25, 2016

Choose a reason for hiding this comment

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

@devversion Agreed. I'll see if I can figure out why it actually fixes it. iirc layout="row" has a rule to have all children use display: block;.

@epelc
Copy link
Contributor Author

epelc commented Apr 25, 2016

So I did some digging, and the icon alignment issue was actually introduced way back in 0.10.1 by the fix for #3383. That fix changed .md-button's display property from flex to inline-block. Which made .md-button's align-items: center; a no op because it requires a flex container. This causes the icon to fallback to default browser alignment for buttons.

The default browser alignment for buttons doesn't appear to use any css properties and is just something specific to buttons. I couldn't find any info about this around the web or in the spec for buttons. It's using some hidden builtin method for vertical alignment, instead of a regular css property.

I'll update my comment shortly.

@epelc
Copy link
Contributor Author

epelc commented Apr 25, 2016

Note I also just tested this with a href buttons and the fix works as expected.

@ThomasBurleson
Copy link
Contributor

👍

@ivoviz
Copy link
Contributor

ivoviz commented Apr 25, 2016

I was curious since I've already opened an issue about this (#7257), so I've tested. It only works for fab buttons. Didn't you misplace the rule @epelc? Also, if you add this to .md-button md-icon as you mentioned in the first comment, it would break buttons with icon and text together.

@epelc
Copy link
Contributor Author

epelc commented Apr 25, 2016

@ivoviz In the original issue I was thinking to add it for .md-icon-button md-icon but then I switched to .md-button md-icon so that it also fixes fabs which do not use md-icon-button.

It does in fact break the layout in a couple cases. I original checked that a href works with an md-icon-button but it is broken with a .md-fab using an a href.

Here is a demo with all the combos of button/a href and the different classes.

@epelc
Copy link
Contributor Author

epelc commented Apr 25, 2016

Here is an updated demo that's working across all cases.

Using this rule

.md-button.md-icon-button,
button.md-button.md-fab {
  md-icon {
    display: block;
  }
}

I'll update my pr to include this.

@ivoviz
Copy link
Contributor

ivoviz commented Apr 25, 2016

@epelc Yup, this new one seems to work, thanks!

@devversion
Copy link
Member

@epelc Just wanted to let you know, that I'll test the PR tomorrow.

@devversion devversion added needs: manual testing This issue or PR needs to have some manual testing and verification done and removed needs: review This PR is waiting on review from the team labels Apr 25, 2016
@devversion
Copy link
Member

devversion commented May 7, 2016

I'm sorry that I didn't test it until now. Issues are sometimes getting lost.

I just checked your PR out and compared with the latest demos.
And the PR seems to be correct / fine.

Some calculations:

  • Button Height: 56px
  • Icon Height: 24px

So the correct top offset (offsetTop) should be (56px - 24px) / 2.

  • Head: 17px
  • PR: 16px (correct)

Since this is actually testable, we should add this as a unit test, because we're able to execute those calculations on Headless browsers as well.

Once the Test is there, LGTM.

@devversion devversion removed the needs: manual testing This issue or PR needs to have some manual testing and verification done label May 7, 2016
@ThomasBurleson ThomasBurleson modified the milestones: 1.1.1, - Backlog May 26, 2016
@Splaktar Splaktar removed this from the - Backlog milestone Jun 28, 2018
@Splaktar Splaktar removed the in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs label Feb 15, 2019
@Splaktar Splaktar added this to the 1.1.0 milestone Feb 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

md-button-icon: Icon not centered
5 participants