()
| 5034 | |
| 5035 | // Utility function to cycle through elements with Tab key |
| 5036 | function selectNextElement() { |
| 5037 | if (elements.length === 0) return; |
| 5038 | |
| 5039 | let currentIndex = -1; |
| 5040 | if (selectedId) { |
| 5041 | currentIndex = elements.findIndex(el => el.id === selectedId); |
| 5042 | } |
| 5043 | |
| 5044 | const nextIndex = (currentIndex + 1) % elements.length; |
| 5045 | selectElement(elements[nextIndex].id, false); |
| 5046 | } |
| 5047 | |
| 5048 | function selectPreviousElement() { |
| 5049 | if (elements.length === 0) return; |