DimitriGilbert / DimitriGilbert/LiteChat

Fix workflow form madness

Open
#16 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
52
Forks
10
PR merge metrics
No merged PRs in 30d

Description

Bug: Form Blur Event Handling Fails

The `onBlur` event handler logic is flawed, causing it to miss blur events for form fields. It only triggers if the blurred field's `name` attribute matches the `lastFocusedField`. This condition fails if a user focuses an element without a `name` attribute, or if they blur a field that was not the *immediately* last focused field.

Additionally, the document-level `blur` and `focus` event listeners, added with the `capture` parameter, are not properly cleaned up. If `formOptions.onBlur` changes, new listeners are added without removing old ones, leading to memory leaks and duplicate event handling.

src/hooks/use-formedible.tsx#L270-L302

https://github.com/DimitriGilbert/LiteChat/blob/2642fe589897bb9548e3b7f04a64869caa469765/src/hooks/use-formedible.tsx#L270-L302

Fix in Cursor

---

_Was this report helpful? Give feedback by reacting with 👍 or 👎_

_Originally posted by @cursor[bot] in https://github.com/DimitriGilbert/LiteChat/pull/14#pullrequestreview-2939746654_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.