diff --git a/src/pyj/popups.pyj b/src/pyj/popups.pyj index af2095e21c..1f78f13cf3 100644 --- a/src/pyj/popups.pyj +++ b/src/pyj/popups.pyj @@ -45,7 +45,9 @@ def create_popup(parent, idprefix): nonlocal popup_count popup_count += 1 pid = (idprefix or 'popup') + '-' + popup_count - div = E.div(id=pid, style='display: none; position: absolute; z-index: {}'.format(POPUP_Z_INDEX)) + # Position has to be fixed so that setting style.top/style.bottom works in + # viewport co-ordinates + div = E.div(id=pid, style='display: none; position: fixed; z-index: {}'.format(POPUP_Z_INDEX)) parent = parent or document.body parent.appendChild(div) return div @@ -166,7 +168,7 @@ class CompletionPopup: cs = c.style cs.left = x + 'px' cs.top = 'auto' if upwards else y + 'px' - cs.bottom = y + 'px' if upwards else 'auto' + cs.bottom = (window.innerHeight - y) + 'px' if upwards else 'auto' cs.width = width + 'px' cs.maxHeight = ((y if upwards else window.innerHeight - y) - 10) + 'px' show_popup(self.container_id, self.associated_widget_ids)