quill icon indicating copy to clipboard operation
quill copied to clipboard

Editor overflows fixed-height container if a toolbar is added

Open jasongisstl opened this issue 11 years ago • 5 comments

If you have a fixed-height container element, and use this to create a Quill editor, the editor's height is set to 100%. So if there's a toolbar present, the editor overflows the bottom of the container by the height of the toolbar.

Please see JS Fiddle

Perhaps I'm missing something?

jasongisstl avatar Sep 24 '15 09:09 jasongisstl

Yes by default Quill's height is 100%. If you want a fixed height + toolbar, one simple way is to fix the height of the Quill editor and toolbar, not the container, and put a border around the container. The editors in the examples page both do this.

Does this solve your problem?

jhchen avatar Sep 25 '15 07:09 jhchen

Thank you for your quick reply, Jason!

I see, yes, that makes sense. Thank you for the explanation.

My use case is that I have a fixed size container, which itself may be dynamically resized by external factors, and I need the editor to always fill it.

Being a lazy good-for-nothing, I was hoping this may be supported out of the box, but I can definitely do this myself by manually setting the heights in JavaScript.

Cheers!

jasongisstl avatar Sep 25 '15 13:09 jasongisstl

Yes ideally Quill could be more helpful but some people want Quill to stay a fixed height and scroll and others want it to fill the rest so Quill just has a simple default.

For your use case you might want to try just fixing the height of the toolbar which allows you to set a padding on the container and negative margin on the toolbar equal to its height. For example: http://jsfiddle.net/8Ljhyzf2/1/.

jhchen avatar Sep 25 '15 22:09 jhchen

Thanks again for the explanation, and for going to the trouble of creating an example for me. That is really going above and beyond!

The example is not perfectly suited to my use case (not that you were to know that) - it doesn't allow for the toolbar to wrap onto multiple lines when it becomes too narrow. But I like the idea and can use this in other areas, i'm sure. However, I do have a solution now (setting the height manually when getting resize events from our framework).

Thanks again for all of your help, and love what you have created with Quill - it's fantastic!

jasongisstl avatar Sep 26 '15 08:09 jasongisstl

I solved this issue with css calc();

.ql-container {
    height: calc(100% - 42px);
  }

rgreenhalge avatar Aug 10 '22 21:08 rgreenhalge