react-quill icon indicating copy to clipboard operation
react-quill copied to clipboard

readOnly doesn't disable the toolbar

Open Pranav-Dakshina opened this issue 5 years ago • 7 comments

I using react-quill 1.3.3

When the props readOnly set to true, it only disables the text. The click events in toolbar still gets triggered.

Pranav-Dakshina avatar Feb 07 '20 14:02 Pranav-Dakshina

same on beta

grachet avatar Mar 31 '20 14:03 grachet

I think this might be a behavior of upstream Quill.js. As can be seen in this codepen, which doesn't use ReactQuill, when readOnly is true, the toolbar remains interactive, even though the buttons do not actually do anything.

Do you experience a similar effect? If so, the problem lies with Quill.

Otherwise, can you provide a reproduction in a Codepen or CodeSandbox showing the issue?

zenoamaro avatar Apr 18 '20 19:04 zenoamaro

The issue is still there 2 years later :/

cfecherolle avatar Dec 16 '22 14:12 cfecherolle

If you specified a theme for react-quill, you can remove the theme attribute to disable the toolbar in readOnly mode or use the bubble theme:

import ReactQuill from 'react-quill';
import 'react-quill/dist/quill.bubble.css';

//

<ReactQuill
    readOnly
    theme="bubble"
    value={textValue}
/>

code-technologist avatar Mar 02 '23 05:03 code-technologist

import ReactQuill from 'react-quill';

function ViewPage() {

  return (
    <ReactQuill theme="bubble" readOnly value="Sample Text"/>
  );
}

thepremiumcoder avatar Mar 02 '23 05:03 thepremiumcoder

import ReactQuill from 'react-quill';

function ViewPage() {

  return (
    <ReactQuill theme="bubble" readOnly value="Sample Text"/>
  );
}

Thanks, use bubble theme or custom style with display: none works. I think this project is abandoned, I'm using react-quill-new, but this bug is also there.

lucasousi avatar Dec 23 '24 01:12 lucasousi

Hindg toolbar will couse layout shift in case of enabling it manually I suggest using opacity and pointer-event like this

.root-disabled {
    pointer-events: none;
    cursor: not-allowed;
}

.root-disabled .ql-toolbar.ql-snow * {
    opacity: 0.85;
}

And use it in JXS like:

<ReactQuill
  readOnly
  className={readOnly ? "root-disabled" : undefined}
/>

disabled:

Image

enabled:

Image

alas1n avatar Jan 23 '25 17:01 alas1n