quill icon indicating copy to clipboard operation
quill copied to clipboard

Text Color Toolbar button doesn't display selected color when using a custom color list

Open jasongisstl opened this issue 10 years ago • 4 comments

If you manually create the font color list for your toolbar, the toolbar button will display the initially selected color. But if you then change the color through the toolbar, the toolbar button will revert to display the color as grey as soon as you type a character. The typed text does still use the correctly selected color however.

Steps for Reproduction

  1. Visit http://codepen.io/jasongiss/pen/BLyRQm
  2. Notice that the initially selected color (green) is displayed in the toolbar button, and stays as you type.
  3. Change the font color using the toolbar button - notice that the new color is now displayed on the toolbar button.
  4. Open the font color droplist - notice that the currently selected color isn't drawn as selected (with a black box around it).
  5. Type a character - the toolbar button reverts to a grey color.

Platforms: Chrome 52 on Mac 10.11.6

Version: 1.0.0-rc4

jasongisstl avatar Sep 05 '16 15:09 jasongisstl

There's a couple things going on here:

  1. The "default" value should just be omitted in the dropdown. Quill works this ways so there's no confusion between not having a particular color and having the default color.
  2. A CSS rule should be added to overwrite the default color in the color picker.
  3. It seems the actual bug is Quill colors do not support rgb values well. Converting to hex works: http://codepen.io/quill/pen/KgdRZr

jhchen avatar Sep 11 '16 04:09 jhchen

Thank you very much, @jhchen for your helpful response. Much appreciated!

One small issue with the example you have provided: the line colour displayed on the font colour toolbar item remains grey by default (rather than green, which is the default colour).

Is it expected that I should also add a CSS rule to control this? E.g:

#toolbar-container .ql-color .ql-color-label.ql-stroke {
  stroke: #00ff00;
}

or should this happen automatically?

jasongisstl avatar Sep 12 '16 08:09 jasongisstl

Yes you should add the css rule for default stroke color as well (updated the codepen). When a different color is selected, it should be handled automatically, but not for the default.

jhchen avatar Sep 12 '16 08:09 jhchen

That's great - thank you very much for clarifying.

jasongisstl avatar Sep 12 '16 09:09 jasongisstl