DEV Community

Discussion on: ReactQuill with NextJS

Collapse
 
devankitkr profile image
Ankit kumar • Edited

toolbar is appearing twice. i don't know how to fix it.. i am using quill inside form element

Collapse
 
akyno profile image
Robersom Aquino

Add this CSS in your global style:

.quill > .ql-toolbar:first-child {
display: none !important;
}

Or in your next.config.js
reactStrictMode: false,

Collapse
 
marcelopatropi profile image
MarceloPatropi

SAme here. Didi you find a solution?

Collapse
 
mrcmesen profile image
Marco Mesen Campos • Edited

Simple solution, I guess not the best:

// component:
<Editor value={html} onChange={setHtml} id="html-editor" />

// css
  #html-editor > div:nth-child(1) {
    display: none !important;
  }
Enter fullscreen mode Exit fullscreen mode

I don't think it's the best either, but definitely better than the previous one

export function TextEditor(props: TextEditorProps) {
  const refElement = useRef<HTMLDivElement>(null);
  const [html, setHtml] = useState('The template will be here');

  useEffect(() => {
    if (refElement.current?.firstChild) {
      const children = Array.from(
        refElement.current.firstChild.childNodes
      ) as HTMLElement[];
      const duplicateTooltips = children.filter((el) => {
        return el.classList.contains('ql-toolbar');
      });
      if (duplicateTooltips.length > 1) {
        duplicateTooltips[0].remove();
      }
    }
  }, [refElement.current]);

  return (
    <div ref={refElement}>
      <Editor value={html} onChange={setHtml} />
    </div>
  );
}

Enter fullscreen mode Exit fullscreen mode