prepare basecoat 1.0 migration

This commit is contained in:
Ronan Berder
2026-06-03 23:08:41 +08:00
parent 7e7d509e90
commit c1cf01da45
125 changed files with 2346 additions and 1169 deletions
+13 -2
View File
@@ -27,6 +27,17 @@
const getValue = (opt) => opt.dataset.value ?? opt.textContent.trim();
const scrollOptionIntoListbox = (option) => {
const optionRect = option.getBoundingClientRect();
const listboxRect = listbox.getBoundingClientRect();
if (optionRect.top < listboxRect.top) {
listbox.scrollTop -= listboxRect.top - optionRect.top;
} else if (optionRect.bottom > listboxRect.bottom) {
listbox.scrollTop += optionRect.bottom - listboxRect.bottom;
}
};
const setActiveOption = (index) => {
if (activeIndex > -1 && options[activeIndex]) {
options[activeIndex].classList.remove('active');
@@ -238,7 +249,7 @@
if (nextVisibleIndex !== currentVisibleIndex) {
const newActiveOption = visibleOptions[nextVisibleIndex];
setActiveOption(options.indexOf(newActiveOption));
newActiveOption.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
scrollOptionIntoListbox(newActiveOption);
}
};
@@ -273,7 +284,7 @@
const selectedOption = listbox.querySelector('[role="option"][aria-selected="true"]');
if (selectedOption) {
setActiveOption(options.indexOf(selectedOption));
selectedOption.scrollIntoView({ block: 'nearest' });
scrollOptionIntoListbox(selectedOption);
}
};