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

bug(mat-select): Span inside of mat-select-trigger causes height to change by 1px #29743

Closed
1 task
theScottyJam opened this issue Sep 16, 2024 · 2 comments · Fixed by #29746
Closed
1 task
Assignees
Labels
area: material/select docs This issue is related to documentation P4 A relatively minor issue that is not relevant to core functions

Comments

@theScottyJam
Copy link

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Using <mat-select-trigger> with an inner span causes the element's height to change by 1px.

More precisely, in an example like this (taken from the website):

    <mat-select-trigger>
      {{toppings.value?.[0] || ''}}
      @if ((toppings.value?.length || 0) > 1) {
        <span class="example-additional-selection">
          (+{{(toppings.value?.length || 0) - 1}} {{toppings.value?.length === 2 ? 'other' : 'others'}})
        </span>
      }
    </mat-select-trigger>

That <span class="..."> portion will, when rendered, cause the size of the select box to grow by 1px.

Reproduction

StackBlitz link: https://stackblitz.com/edit/33iirb?file=package.json
Steps to reproduce:

  1. The bug can be seen in the Angular Material's example - https://material.angular.io/components/select/overview#customizing-the-trigger-label - the above StackBlitz is the same one from the example.
  2. Expand the select box and select multiple items to make the "(+2 items)" span appear. Notice that the select box grows by 1px when this happens.

Expected Behavior

It should stay the same size.

If there's some sort of CSS rules/something that needs to apply to keep this the same size, that should be demonstrated in the example on the website.

Actual Behavior

It make's the page content bob up and down by 1px when the span is shown/hidden.

Environment

  • Angular: 19.0
  • CDK/Material: 18.2.4
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Tested on Fedora and Ubuntu
@theScottyJam theScottyJam added the needs triage This issue needs to be triaged by the team label Sep 16, 2024
@theScottyJam theScottyJam changed the title bug(mat-select): TITLE bug(mat-select): Span inside of mat-select-trigger causes height to change by 1px Sep 16, 2024
crisbeto added a commit to crisbeto/material2 that referenced this issue Sep 17, 2024
…example

The `mat-select` in the custom trigger example was jumping around, because the projected `span` didn't have a `line-height`.

Fixes angular#29743.
@crisbeto
Copy link
Member

You can fix it by setting line-height: 1 on the span. I've sent a fix at #29746.

@crisbeto crisbeto self-assigned this Sep 17, 2024
@crisbeto crisbeto added docs This issue is related to documentation P4 A relatively minor issue that is not relevant to core functions area: material/select and removed needs triage This issue needs to be triaged by the team labels Sep 17, 2024
crisbeto added a commit that referenced this issue Sep 17, 2024
…example (#29746)

The `mat-select` in the custom trigger example was jumping around, because the projected `span` didn't have a `line-height`.

Fixes #29743.
crisbeto added a commit that referenced this issue Sep 17, 2024
…example (#29746)

The `mat-select` in the custom trigger example was jumping around, because the projected `span` didn't have a `line-height`.

Fixes #29743.

(cherry picked from commit 2dd269e)
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/select docs This issue is related to documentation P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants