+ // detect whether the menu is outside the viewport, and adjust the position
+ // there is a bug in fomantic's builtin `direction` function, in some cases (when the menu width is only a little larger) it wrongly opens the menu at right and triggers the scrollbar.
+ elMenu.classList.add(classNames.loading);
+ if (elMenu.getBoundingClientRect().right > document.documentElement.clientWidth) {
+ elMenu.classList.add(classNames.leftward);
+ }
+ elMenu.classList.remove(classNames.loading);
+ };
}
// for static dropdown elements (generated by server-side template), prepare them with necessary aria attributes