Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Weird bug where enter key submission of form only works once until I tab in and out of desktop application and then I can submit form again. (ElectronJS)
Post Flair (click to view more posts with a particular flair)
Post Body

Hello,

I'm running into this weird bug where I want to submit a form when the user presses the enter key, but the form submission only works once when the enter key gets pressed and won't work again until I tab in and out of the desktop application. The input is required and is validated to see if the string inputted is a valid YouTube link.

The application is a desktop application using Chakra-UI, React.js, and ElectronJS. I am using react-hook-form for form validation. I honestly have no idea why this is happening and have been stuck on this for days. Any help would be appreciated. Thank you!

YouTubeLink.js

export default function YoutubeLink() {
  let navigate = useNavigate() // navigation function for react router

  const [link, setLink] = useState(""); // variable to hold input string

  const {
    handleSubmit, //takes as input onSubmit
    register, // function used to link an input to form state
    formState: { errors },
  } = useForm();

  const handleChange = (event) => {
    setLink(event.target.value);
  }

  const onSubmit = (values) => {
    console.log(values)
    navigate('/transcribe', {
      state: {
        videoID: getYouTubeID(link)
      }
    })
  }

  const onError = (e) => {
    console.log('Error occured: ', e)
  }

  return (
    <form onSubmit={handleSubmit(onSubmit, onError)}>
      <FormControl isInvalid={errors.link}>
        <InputGroup width="lg">
          <Input
            id="link"
            {...register("link", {
              required: {
                value: true,
                message: "This is required."
              },
              validate: (link) => matchYouTubeURL(link) || "Invalid YouTube Link"
            })}
            pr="4.5rem"
            type="text"
            value={link}
            onChange={handleChange}
            placeholder="YouTube Link"
          />
          <InputRightElement width="4.5rem">
            <Button h="1.75rem" mr="8px" size="sm" type="submit">
              Submit
            </Button>
          </InputRightElement>
        </InputGroup>
        <FormErrorMessage>
          {errors.link && errors.link.message}
        </FormErrorMessage>
      </FormControl>
    </form>
  );
}

Author
Account Strength
80%
Account Age
11 years
Verified Email
Yes
Verified Flair
No
Total Karma
301
Link Karma
66
Comment Karma
235
Profile updated: 3 days ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago