diff --git a/src/index.js b/src/index.js index 664a7bf..e19f7f5 100644 --- a/src/index.js +++ b/src/index.js @@ -121,7 +121,10 @@ Component.register('DataTable', container => { state.activeField = field; state.activeFieldId = field.id; menu.style.display = 'block'; const rect = btn.getBoundingClientRect(), rootRect = container.getBoundingClientRect(); - menu.style.left = (rect.right - rootRect.left - (menu.offsetWidth || 260)) + 'px'; + const menuWidth = menu.offsetWidth || 260; + let leftPos = rect.right - rootRect.left - menuWidth; + if (leftPos < 0) leftPos = Math.max(0, rect.left - rootRect.left); + menu.style.left = leftPos + 'px'; menu.style.top = (rect.bottom - rootRect.top + 5) + 'px'; const onGlobalClick = (ev) => {