()
| 5046 | } |
| 5047 | |
| 5048 | function selectPreviousElement() { |
| 5049 | if (elements.length === 0) return; |
| 5050 | |
| 5051 | let currentIndex = -1; |
| 5052 | if (selectedId) { |
| 5053 | currentIndex = elements.findIndex(el => el.id === selectedId); |
| 5054 | } |
| 5055 | |
| 5056 | const prevIndex = currentIndex <= 0 ? elements.length - 1 : currentIndex - 1; |
| 5057 | selectElement(elements[prevIndex].id, false); |
| 5058 | } |
| 5059 | |
| 5060 | // Utility function to bring element to front/back |
| 5061 | function bringToFront(elementId) { |