mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-02-01 22:47:40 +00:00
fix: validate coordinates before elementsFromPoint on Firefox mobile (#1992)
Firefox mobile drag events can provide non-finite coordinate values
(`undefined`, `NaN`, `Infinity`) which cause
`document.elementsFromPoint()` to throw: "Argument 1 is not a finite
floating-point value."
**Changes**
- Added `Number.isFinite()` validation in `findProjectIdAtPosition()`
before calling `elementsFromPoint()`
- Returns `null` when coordinates are invalid, gracefully aborting the
drop operation
```typescript
function findProjectIdAtPosition(mouseX: number, mouseY: number): number | null {
// Validate coordinates are finite numbers (required by elementsFromPoint)
if (!Number.isFinite(mouseX) || !Number.isFinite(mouseY)) {
return null
}
const elementsUnderMouse = document.elementsFromPoint(mouseX, mouseY)
// ... rest of implementation
}
```
The caller already handles `null` returns appropriately, treating it as
"no valid drop target found."
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kolaente <13721712+kolaente@users.noreply.github.com>
This commit is contained in:
@@ -10,6 +10,12 @@ import {success, error} from '@/message'
|
||||
* Searches through elements under the mouse and their parents for data-project-id attribute.
|
||||
*/
|
||||
function findProjectIdAtPosition(mouseX: number, mouseY: number): number | null {
|
||||
// Validate coordinates are finite numbers (required by elementsFromPoint)
|
||||
// This prevents errors on Firefox mobile where touch events may provide invalid coordinates
|
||||
if (!Number.isFinite(mouseX) || !Number.isFinite(mouseY)) {
|
||||
return null
|
||||
}
|
||||
|
||||
const elementsUnderMouse = document.elementsFromPoint(mouseX, mouseY)
|
||||
|
||||
for (const el of elementsUnderMouse) {
|
||||
|
||||
Reference in New Issue
Block a user