Paper checkbox and -webkit-column-count

Issue

This is something I have been researching for a while already but I am not able to find out what’s happening here.

On this example you can see how there is a list of check boxes that are spread over a div using the css rule -webkit-column-count.

The problem is that the check-mark is hidden for some reason on all the columns but the first one. Do you have any tip to fix this?

Here I attach an small example but please check my jsfiddle for a better descriptive view of the situation. Thanks!

.valueLabel {
  /* height: 24px; */
  padding: 7px 12px;
  width: 400px;
}
.valueLabel paper-checkbox {
  margin-right: 12px;
}
.valueLabel paper-checkbox::shadow #ink[checked] {
  color: #f39200;
}
.valueLabel paper-checkbox::shadow #checkbox.checked {
  border-color: #f39200;
  background-color: #f39200;
  /* Version 0.7 paper-checkbox */
}
/* COLUMNS */

.valuesContainer {
  overflow-y: scroll;
  padding: 0px 16px;
}
.valuesContainer > #valuesDiv {
  -webkit-column-break-inside: avoid;
  -moz-column-break-inside: avoid;
  column-break-inside: avoid;
  -webkit-column-count: 4;
  -moz-column-count: 4;
  column-count: 4;
  -webkit-column-gap: 0px;
  -moz-column-gap: 0px;
  column-gap: 0px;
}
.valuesContainer > #valuesDiv .valuesGroup {
  display: inline-block;
}
.valuesContainer > #valuesDiv .valuesGroup > span {
  text-transform: uppercase;
}
/* LAYOUT WRAP */

.valuesContainer > core-label {
  width: 30%;
  /* 3 COLUMNS */
  line-height: 16px;
  font-size: small;
}
.valuesContainer > #valuesDiv core-label.valueLabel {
  display: inline-flex;
}
/* FIX THAT I USED TO SHOW ALL CHECKS WHEN THEY ARE ON COLUMNS, USED ON PAPER ELEMENTS >= v0.7 */

/* IT DOES NOT WORK ANYMORE */

.valueLabel paper-checkbox::shadow #checkbox.checked #checkmark {
  position: fixed;
  margin-top: 2px;
  margin-left: 2px;
}
<script src="https://www.polymer-project.org/0.5/components/webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="https://www.polymer-project.org/0.5/components/polymer/polymer.html">
<link rel="import" href="https://www.polymer-project.org/0.5/components/paper-elements/paper-elements.html">
<link rel="import" href="https://www.polymer-project.org/0.5/components/core-elements/core-elements.html">
<div class="valuesContainer">
  <div id="valuesDiv">
    <core-label class="valueLabel" horizontal="" layout="" id="core-label-0">
      <paper-checkbox id="1" checked></paper-checkbox>
      <div>January</div>
    </core-label>

    <core-label class="valueLabel" horizontal="" layout="" id="core-label-1">
      <paper-checkbox id="2"></paper-checkbox>
      <div>February</div>
    </core-label>

    <core-label class="valueLabel" horizontal="" layout="" id="core-label-2">
      <paper-checkbox id="3" checked></paper-checkbox>
      <div>March</div>
    </core-label>

    <core-label class="valueLabel" horizontal="" layout="" id="core-label-3">
      <paper-checkbox id="4" checked></paper-checkbox>
      <div>April</div>
    </core-label>

    <core-label class="valueLabel" horizontal="" layout="" id="core-label-4">
      <paper-checkbox id="5"></paper-checkbox>
      <div>May</div>
    </core-label>

  </div>
</div>

Solution

You’re running into a rendering bug. One way to try to correct this is to force GPU rendering. There are a few ways to do that, and my favorite is to use transform:translate3d(0,0,0). The issue with that, however, is that the element that needs it (#checkbox.checked #checkmark) already has a transform. You can achieve the same results by setting the backface visibility. I do that in the demo below with the following rule:

.valueLabel paper-checkbox::shadow #checkbox.checked #checkmark {
   ...
   -webkit-backface-visibility: hidden;
   -moz-backface-visibility: hidden;
   -ms-backface-visibility: hidden;
   backface-visibility: hidden;
}

Demo

.valueLabel {
  /* height: 24px; */
  padding: 7px 12px;
  width: 400px;
}
.valueLabel paper-checkbox {
  margin-right: 12px;
}
.valueLabel paper-checkbox::shadow #ink[checked] {
  color: #f39200;
}
.valueLabel paper-checkbox::shadow #checkbox.checked {
  border-color: #f39200;
  background-color: #f39200;
  /* Version 0.7 paper-checkbox */
}
/* COLUMNS */

.valuesContainer {
  overflow-y: scroll;
  padding: 0px 16px;
}
.valuesContainer > #valuesDiv {
  -webkit-column-break-inside: avoid;
  -moz-column-break-inside: avoid;
  column-break-inside: avoid;
  -webkit-column-count: 4;
  -moz-column-count: 4;
  column-count: 4;
  -webkit-column-gap: 0px;
  -moz-column-gap: 0px;
  column-gap: 0px;
}
.valuesContainer > #valuesDiv .valuesGroup {
  display: inline-block;
}
.valuesContainer > #valuesDiv .valuesGroup > span {
  text-transform: uppercase;
}
/* LAYOUT WRAP */

.valuesContainer > core-label {
  width: 30%;
  /* 3 COLUMNS */
  line-height: 16px;
  font-size: small;
}
.valuesContainer > #valuesDiv core-label.valueLabel {
  display: inline-flex;
}
/* FIX THAT I USED TO SHOW ALL CHECKS WHEN THEY ARE ON COLUMNS, USED ON PAPER ELEMENTS >= v0.7 */

/* IT DOES NOT WORK ANYMORE */

.valueLabel paper-checkbox::shadow #checkbox.checked #checkmark {
  position: fixed;
  margin-top: 2px;
  margin-left: 2px;
  -webkit-backface-visibility: hidden;
  -moz-backface-visibility: hidden;
  -ms-backface-visibility: hidden;
  backface-visibility: hidden;
}
<script src="https://www.polymer-project.org/0.5/components/webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="https://www.polymer-project.org/0.5/components/polymer/polymer.html">
<link rel="import" href="https://www.polymer-project.org/0.5/components/paper-elements/paper-elements.html">
<link rel="import" href="https://www.polymer-project.org/0.5/components/core-elements/core-elements.html">
<div class="valuesContainer">
  <div id="valuesDiv">
    <core-label class="valueLabel" horizontal="" layout="" id="core-label-0">
      <paper-checkbox id="1" checked></paper-checkbox>
      <div>January</div>
    </core-label>

    <core-label class="valueLabel" horizontal="" layout="" id="core-label-1">
      <paper-checkbox id="2"></paper-checkbox>
      <div>February</div>
    </core-label>

    <core-label class="valueLabel" horizontal="" layout="" id="core-label-2">
      <paper-checkbox id="3" checked></paper-checkbox>
      <div>March</div>
    </core-label>

    <core-label class="valueLabel" horizontal="" layout="" id="core-label-3">
      <paper-checkbox id="4" checked></paper-checkbox>
      <div>April</div>
    </core-label>

    <core-label class="valueLabel" horizontal="" layout="" id="core-label-4">
      <paper-checkbox id="5"></paper-checkbox>
      <div>May</div>
    </core-label>

  </div>
</div>

Answered By – Joseph Marikle

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.