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

fix: delay in displaying comment length limit error #33848

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hooks/useHandleExceedMaxCommentLength.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const useHandleExceedMaxCommentLength = () => {
[hasExceededMaxCommentLength],
);

const validateCommentMaxLength = useMemo(() => _.debounce(handleValueChange, 1500), [handleValueChange]);
const validateCommentMaxLength = useMemo(() => _.debounce(handleValueChange, 500, {leading: true}), [handleValueChange]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aswin-s I don't think we need to reduce the timeout. Any reason to do it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.5 seconds feels a bit too much in my testing. It waits for 1.5 seconds after last invocation to trigger the check. 500ms felt like a safe middle ground. The issue gets fixed even without the change in timing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdulrahuman5196 Do you think it is safe to revert the timeout change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should only do the computation once the user stops typing and gives a pause, since it could add computational overhead to compute the error sooner. That's why I assume we kept it at 1500 ms. I think for this PR, it should be fine to leave it as it is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdulrahuman5196 I've reverted the timeout change.


return {hasExceededMaxCommentLength, validateCommentMaxLength};
};
Expand Down
Loading