Minimalistic utility to add tab wrapping to any element, such as dialogs and popups.
using npm
npm install @devlop/tabwrap<divclass="dialog"><inputtype="text"><!-- switch + tab here should switch focus to the last <input> --><inputtype="text"><inputtype="text"><!-- tab here should switch focus to the first <input>--></template>importtabwrapfrom'@devlop/tabwrap';tabwrap(document.querySelector('div.dialog'));If you have many places you want to add tab wrapping it can usefull to give all your elements you wish to target
the same attribute, for example data-tabwrap, then it's easy to add tab wrapping to them all like this.
importtabwrapfrom'@devlop/tabwrap';document.querySelectorAll('[data-tabwrap]').forEach(function(element){tabwrap(element);});