Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
react onmouseover while onmousedown

I'm trying to implement the same effect google sheets and ms excel has, that you press on one cell and move the mouse to highlight other close cells, the problem is when the onMouseDown event is fired and I'm still holding the mouse down and move the mouse over other cells - the onMouseOver cannot be fired, the mouse cursor itself turns into the not-allowed sign, any suggestions how to solve it?

Test.js

import React, { useRef } from 'react'

function Test() {
    const myTable = useRef(null)
    return (
            <>
            <table ref={myTable}>
                <tbody>
                    {
                        [...Array(4)].map((row, rowIndex) => (
                            <tr>
                                {
                                    [...Array(4)].map((col, colIndex) => (
                                        <td style={{
                                            border: '1px black solid',
                                            width: '100px',
                                            height: '100px'
                                          }}
                                            onMouseDown={(e) => console.log('mouse down')} 
                                            onMouseOver={(e) => console.log('mouse over')}>
                                        </td>
                                    ))
                                }
                            </tr>
                        )

                        )
                    }
                </tbody>
            </table>
        </>
    )
}

export default Test

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

problem solved by adding e.preventDefault()

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!