title: ReactJS: Auto save form by using .click removes focus
body: <p>I have a form which I am auto saving by triggering a click every 1.5secs by targeting the button element and performing a .click:</p>
  <pre><code>let intervalID;
    useEffect(() =&gt; {
    if (editing) {
         intervalID = setInterval(() =&gt; {
         const formSubmitButton = document.querySelector(&quot;.btnaa&quot;);
         formSubmitButton.click();
         }, 1500);
  </code></pre>
  <p>This works well for the most part, but on modals etc it removes the focus and closes it.</p>
  <p>How do I prevent this from happening? I tried using e.preventDefault() but then that does not save the form. Essentially what I am trying to do, is trigger the form to submit without removing focus.</p>