DimitriGilbert / DimitriGilbert/LiteChat
Fix workflow form madness
- 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
---
_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.