https://lukemurphey.net/https://lukemurphey.net/favicon.ico2022-01-06T18:24:11ZLukeMurphey.netTextCritical.net - Bug #2869: Shortcut keys for next verse act weirdhttps://lukemurphey.net/issues/2869?journal_id=78162022-01-06T18:24:11ZLuke Murphey
<ul></ul>Repro:
<ul>
<li>Open work</li>
<li>Press Shift+right several times; note that it moves several chapters</li>
</ul> TextCritical.net - Bug #2869: Shortcut keys for next verse act weirdhttps://lukemurphey.net/issues/2869?journal_id=78172022-01-07T03:26:34ZLuke Murphey
<ul></ul><pre>
Uncaught TypeError: Cannot read properties of null (reading 'next_chapter')
</pre> TextCritical.net - Bug #2869: Shortcut keys for next verse act weirdhttps://lukemurphey.net/issues/2869?journal_id=78182022-01-07T05:40:54ZLuke Murphey
<ul></ul><p>Questions:</p>
<ul>
<li>What is the related stack trace?
<ul>
<li>readingMenuBar::upHandler()</li>
</ul>
</li>
<li>Is the handler not getting removed properly?</li>
<li>Is the problem due to not having an empty array of dependencies after useEffect?
<ul>
<li><a class="external" href="https://www.pluralsight.com/guides/event-listeners-in-react-components">https://www.pluralsight.com/guides/event-listeners-in-react-components</a></li>
<li>This gets rid of the multiple addHandler() registrations but it also breaks it</li>
</ul>
</li>
<li>When does useEffect()'s cleanup get called?</li>
<li>Does this improve if I only add the handler if both goToNextChapter and goToPriorChapter are set?
<ul>
<li>No change</li>
</ul>
</li>
<li>Does this work if I keep the handler around and only apply it if doesn't yet exist?
<ul>
<li>No change</li>
</ul></li>
</ul>
Observations:
<ul>
<li>upHandler() is getting called several times</li>
<li>addHandler() gets called 7 times on a normal load
<ul>
<li>removeHandler() gets called 6 times</li>
</ul>
</li>
<li>It looks like the handlers are not getting removed
<ul>
<li>getEventListeners(window).keyup.length</li>
<li>These keep increasing</li>
</ul></li>
</ul>
Conclusion:
<ul>
<li>I wasn't deregistering the handlers correctly</li>
</ul> TextCritical.net - Bug #2869: Shortcut keys for next verse act weirdhttps://lukemurphey.net/issues/2869?journal_id=78192022-01-07T05:41:07ZLuke Murphey
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul>