attoae / quill-table-better

A module that enhances the table functionality of Quill.
MIT License
59 stars 5 forks source link

[Request] Listening to the click event outside the button #20

Closed S1owe closed 2 months ago

S1owe commented 2 months ago

It would be nice to add click tracking over time outside the table display button. So that when you click outside the button (the drop-down window for creating a table), the drop-down window closes. Now to close the window, you either need to click on the button or create a table

Снимок экрана 2024-09-06 в 14 13 42
attoae commented 2 months ago

Do you want only one dropdown window for creating tables to exist on the page ?

S1owe commented 2 months ago

Yes. I need one drop-down window. If you click on the create table button in the second editor, the first one should close. The same logic applies when clicking outside the table creation element

S1owe commented 2 months ago

I solved this problem as follows, I placed the following fragment in the registerToolbarTable method

document.addEventListener('click', (e: MouseEvent) => {
      const isClickOnBtn = e.composedPath().includes(button);
      if (isClickOnBtn) return;

      const tableEl = toolbar.container.querySelector('div.ql-table-select-container');
      if (!tableEl.classList.contains('ql-hidden')) this.tableSelect.hide(tableEl);
    });
Снимок экрана 2024-09-06 в 14 46 23
attoae commented 2 months ago

Okay, I will handle this issue.