Fix positioning of completion popup above widgets

This commit is contained in:
Kovid Goyal 2016-08-11 18:19:58 +05:30
parent c40995b2b6
commit df1d52a7ef

View File

@ -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)