components icon indicating copy to clipboard operation
components copied to clipboard

[Table] Checkbox moves place when clicked

Open tawalters61 opened this issue 9 years ago • 22 comments

Bug, feature request, or proposal:

Bug

What is the expected behavior?

When selecting a checkbox within a table, the highlighted selection highlighting should not move up.

What is the current behavior?

The alignment of the highlighting is not aligned with the checkbox itself.

What are the steps to reproduce?

Providing a StackBlitz/Plunker (or similar) is the best way to get the team to see your issue.
Plunker starter (using on @master): https://goo.gl/uDmqyY
StackBlitz starter (using latest npm release): https://goo.gl/wwnhMV

This existing table example at the following URL does not work properly with material 5.0.0*

https://stackblitz.com/edit/angular-material2-table

What is the use-case or motivation for changing an existing behavior?

It's a bug

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Material: 5.0.0-rc0, 5.0.0-rc.1 The bug does not exist in 2.0.0-beta.12

Is there anything else we should know?

No

tawalters61 avatar Nov 22 '17 20:11 tawalters61

@tawalters61 I don't follow what the issue is you're reporting.

jelbourn avatar Nov 22 '17 23:11 jelbourn

When selecting a checkbox within a table cell, the checkbox moves up several pixels, causing it not to be aligned properly. Also, the 'special effects' are clipped. In the link above, it works correctly, because the example online is using a pre-5.0.0 version of Material . But, if the same example is run with Material 5.0.0-rc0 or 5.0.0-rc.1, the problem occurs.

tawalters61 avatar Nov 23 '17 02:11 tawalters61

@jelbourn The checkbox is only moved when you directly click on it. If the ripple effect is not applied, then everything is fine

checkbox_bug

c0dewhisper avatar Nov 23 '17 03:11 c0dewhisper

Yes, this is what I am seeing. This problem does not exist in the pre-5 versions.

tawalters61 avatar Nov 23 '17 05:11 tawalters61

Same as this issue: https://github.com/angular/material2/issues/8517 . One Workaround to wait the fix is:

  mat-cell {
    overflow: visible;
  }

wandri avatar Nov 23 '17 08:11 wandri

Thanks! This worked!

tawalters61 avatar Nov 23 '17 18:11 tawalters61

Actually, I remember having this effect since way before Material 5.0.0-rc0 on Windows7/Chrome/Firefox/Typescript 2.4.x.

volei avatar Nov 25 '17 01:11 volei

Could be related to #8517 and #8588.

merschel avatar Nov 27 '17 09:11 merschel

The issue indeed is due to overflow. For some reason the checkbox doesn't like how the cell's overflow is set and it moves when clicked. Need to investigate why the checkbox starts correctly but then moves on click

andrewseguin avatar Nov 27 '17 18:11 andrewseguin

// Bug fix for mat-checkbox inside a mat-cell
mat-cell, .mat-header-cell{
   overflow: visible;
 }

If you want to put a checkbox in the header (i.e "Select All" checkbox) add .mat-header-cell to the CSS as well.

pacurtin avatar Dec 03 '17 03:12 pacurtin

Same in @angular/[email protected]

I had to be more specific to override defaults

mat-cell.mat-cell, mat-header-cell.mat-header-cell { overflow: visible; }

tonysamperi avatar Jan 19 '18 08:01 tonysamperi

I have the same problem when using an unlabelled mat-checkbox inside mat-cell. The problem disappeared when I gave it a label. For the present I use <mat-checkbox>&nbsp;</mat-checkbox> as I find it quicker that altering the css. Of course, this only works if you can afford the extra space!

DouglasWebster avatar Jan 22 '18 15:01 DouglasWebster

@DouglasWebster Good to know! Actually I could have afforded to "steal" extra space...I'll give it a try with the next table ;)

tonysamperi avatar Jan 22 '18 16:01 tonysamperi

@wandri @pacurtin @tonysamperi solution fixes the checkbox issue, however it mess up other columns alignment

arundhaj avatar Mar 06 '18 17:03 arundhaj

@arundhaj no it doesn't. Tomorrow I'll post a screen. Probably you have a different environment...

checkbox

tonysamperi avatar Mar 06 '18 20:03 tonysamperi

Any ETA for a non-hacky fix for this?

lostllama avatar Apr 25 '18 08:04 lostllama

@lostllama does it work for you the css rule in the styles.css ?

tonysamperi avatar Apr 25 '18 09:04 tonysamperi

@DouglasWebster workaround worked for me, @arundhaj is right, it messes the column alignment, I'm using version 5.0.0 of angular material.

mgs96 avatar Aug 08 '18 20:08 mgs96

I have checkbox at the bottom of page & in mobile devices when click on it moves scrolls & hides below. So we are unable to check/uncheck in mobile devices.

ezgif-4-dc9dc44ceaad

Any resolution for this?

akvaliya avatar Oct 11 '19 11:10 akvaliya

I have checkbox at the bottom of page & in mobile devices when click on it moves scrolls & hides below. So we are unable to check/uncheck in mobile devices.

ezgif-4-dc9dc44ceaad

Any resolution for this?

I am facing the same issue. looks like mat-option does not support float property and gives this kind of behaviour to the form.

Any suggestion for an alternate of float ??

abha01singh avatar Apr 16 '20 13:04 abha01singh