components icon indicating copy to clipboard operation
components copied to clipboard

bug([Mat Buttons: (not fabs]): Placing Mat Buttons inside a <a> with display: flex brings back link underline text

Open mikejunt opened this issue 6 years ago • 3 comments

https://stackblitz.com/github/mikejunt/mat-button-example

Steps to reproduce:

  1. Place a button with any mat-button directive (button, raised, flat, stroked, icon) inside an anchor tag
  2. Style the anchor tag with display: flex (for example to use justify-content or align-content

Expected Behavior

In all other circumstances, link styling is removed from button text on material buttons that are links

Actual Behavior

Underlines. Note that this behavior is NOT present if you use display: -webkit-box.

Environment

  • Angular: 9.0.5
  • CDK/Material: 9.1.2
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 10 Pro

mikejunt avatar Mar 12 '20 20:03 mikejunt

I don't think this falls under the purview Angular Material; the components apply their own styles, but we don't touch the styles for elements the library doesn't "own" (in this case, a plain <a>). It would be up to the application to reset any browser-agent styles.

jelbourn avatar Mar 13 '20 02:03 jelbourn

That's fair though using a button for a link is a fairly common use case, and the issue is caused by the display: flex. Removing it, or having an intermediate element (eg a div in between the anchor and the button) removes the issue.

mikejunt avatar Mar 13 '20 14:03 mikejunt

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.