code refactor
This commit is contained in:
@@ -218,13 +218,12 @@ function onPrimaryItemClicked(item: unknown): void {
|
|||||||
|
|
||||||
if (props.autoUpdateMenuPosition) {
|
if (props.autoUpdateMenuPosition) {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
||||||
const mainSelectRect = document.querySelector('.two-column-main-select')?.getBoundingClientRect();
|
const mainSelectRect = document.querySelector('.two-column-main-select')?.getBoundingClientRect();
|
||||||
const selectMenu = document.querySelector('.two-column-select-menu') as (HTMLElement | null);
|
const selectMenu = document.querySelector('.two-column-select-menu') as (HTMLElement | null);
|
||||||
const selectMenuRect = selectMenu?.getBoundingClientRect();
|
const selectMenuRect = selectMenu?.getBoundingClientRect();
|
||||||
|
|
||||||
if (mainSelectRect && selectMenu && selectMenuRect) {
|
if (mainSelectRect && selectMenu && selectMenuRect) {
|
||||||
const newTop = scrollTop + mainSelectRect.top + mainSelectRect.height + 0.5;
|
const newTop = Math.round(mainSelectRect.top + mainSelectRect.height);
|
||||||
|
|
||||||
if (newTop + selectMenuRect.height < document.documentElement.scrollHeight) {
|
if (newTop + selectMenuRect.height < document.documentElement.scrollHeight) {
|
||||||
selectMenu.style.top = newTop + 'px';
|
selectMenu.style.top = newTop + 'px';
|
||||||
|
|||||||
Reference in New Issue
Block a user