(hdr, cnt)
| 5638 | } |
| 5639 | |
| 5640 | function focusSectionIntoView(hdr, cnt) { |
| 5641 | if (!hdr || !cnt) return; |
| 5642 | const scroller = hdr.closest(".modal-content") || document.scrollingElement || document.documentElement; |
| 5643 | if (!scroller) { |
| 5644 | try { |
| 5645 | hdr.scrollIntoView({ behavior: "smooth", block: "start", inline: "nearest" }); |
| 5646 | } catch (e) { |
| 5647 | hdr.scrollIntoView(); |
| 5648 | } |
| 5649 | return; |
| 5650 | } |
| 5651 | |
| 5652 | const padding = 12; |
| 5653 | const scrollerRect = scroller.getBoundingClientRect(); |
| 5654 | const headerRect = hdr.getBoundingClientRect(); |
| 5655 | const targetTop = scroller.scrollTop + (headerRect.top - scrollerRect.top) - padding; |
| 5656 | const nextTop = Math.max(0, targetTop); |
| 5657 | if (Math.abs(nextTop - scroller.scrollTop) < 1) return; |
| 5658 | try { |
| 5659 | if (typeof scroller.scrollTo === "function") { |
| 5660 | scroller.scrollTo({ top: nextTop, behavior: "smooth" }); |
| 5661 | setTimeout(() => { |
| 5662 | if (Math.abs(scroller.scrollTop - nextTop) > 1) { |
| 5663 | scroller.scrollTop = nextTop; |
| 5664 | } |
| 5665 | }, 40); |
| 5666 | return; |
| 5667 | } |
| 5668 | } catch (e) { |
| 5669 | // Fallback for browsers that don't accept scroll options. |
| 5670 | } |
| 5671 | scroller.scrollTop = nextTop; |
| 5672 | } |
| 5673 | |
| 5674 | function scheduleSectionFocus(hdr, cnt) { |
| 5675 | if (!hdr || !cnt) return; |
no outgoing calls
no test coverage detected