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

Remove random key from comment field #4177

Merged
merged 1 commit into from Oct 12, 2023
Merged

Remove random key from comment field #4177

merged 1 commit into from Oct 12, 2023

Conversation

norbye
Copy link
Member

@norbye norbye commented Oct 10, 2023

Description

Removes the wait introduced in #4176

CommentFields were set to have a random key (why I do not know), that would make it re-render excessively (and thus clear the focus and content of the new comment). This removes the key, and rather handles form resetting by using the form.change() method.

Changes done to TextInput.ts were done to avoid bugs that were discovered while trying another approach.

  • When inputRef was used as a parameter in useRef(), it did not update inputRef when newInputRef was used. Thus it was not possible to pass a ref through to the component.
  • Small typescript errors

Result

When run on my machine this works quite well, and I can start writing comments before all the content of the page has been loaded - which was not the case previously.

To see if this resolves the cypress-bug, we'll probably have to wait and see. This passed cypress on the first attempt, but lately it has worked some times and some times not, so it's no guarantee.

Testing

  • I have thoroughly tested my changes.

Have been testing that the comment form works as expected in the event view.

Rather handle content reset with form functions when desired
@norbye norbye added review-needed Pull requests that need review bug-fix Pull requests that fix a bug labels Oct 10, 2023
Copy link
Member

@ivarnakken ivarnakken left a comment

Choose a reason for hiding this comment

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

This is the greatest thing since sliced bread!😍😍Thanks!!

Comment on lines +53 to +54
// Clear the form value
form.change('text', undefined);
Copy link
Member

Choose a reason for hiding this comment

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

Clever!

@norbye norbye added the approved Pull requests that have been approved label Oct 11, 2023
@ivarnakken ivarnakken added ready-to-merge Pull requests that have been approved and are ready to be merged and removed review-needed Pull requests that need review labels Oct 12, 2023
@ivarnakken ivarnakken merged commit ba895fe into master Oct 12, 2023
4 checks passed
@ivarnakken ivarnakken deleted the comment-bug branch October 12, 2023 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Pull requests that have been approved bug-fix Pull requests that fix a bug ready-to-merge Pull requests that have been approved and are ready to be merged
Projects
None yet
3 participants