Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Right click outside the table throw exception: Cannot read properties of undefined (reading 'getBoundingClientRect') #77

Open
rceraline opened this issue Sep 17, 2021 · 2 comments

Comments

@rceraline
Copy link

rceraline commented Sep 17, 2021

Hi,

I noticed an error when using the table. Here is the repro steps:

  1. Insert a table
  2. Click inside a cell to activate the table
  3. Right click outside the table

Expected behavior: no error
Actual behavior: Cannot read properties of undefined (reading 'getBoundingClientRect')

The scenario can be reproduced here: https://codepen.io/soccerloway/pen/WWJowj

image

@tkefauver
Copy link

I had this problem too but didn't realize this was the cause!

I was able to workaround it adding a tunneled 'contextmenu' event listener on window and rejecting the right click if a cell is selected and the mouse point on the click is NOT in the table's <tbody> element's (specifically that element any higher will return the whole block width) bounding client rect. using getBoundingClientRect() and {x: e.clientX, y: e.clientY} for the collision detected.

@mattheusbr
Copy link

I solved the problem by adding the line

   if(!cellNode)
        return true;  

After

      const cellNode = path.filter(node => {
        return node.tagName &&
          node.tagName.toUpperCase() === 'TD' &&
          node.getAttribute('data-row')
      })[0]

Inside the Listener

    this.quill.root.addEventListener('contextmenu', (evt) => { 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants