Skip to content

Commit

Permalink
fix: nodes as targets
Browse files Browse the repository at this point in the history
  • Loading branch information
s-cork committed Nov 27, 2024
1 parent ffadb44 commit d10418e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
https://github.com/anvilistas/anvil-extras/pull/573
* persistence - linked class attributes were not handling None values correctly
https://github.com/anvilistas/anvil-extras/pull/577
* popover - fix bug with popovers not handling dom nodes correctly
https://github.com/anvilistas/anvil-extras/pull/580

## Enhancements
* tabs - tab color can now be a css var and better support for css colors in general
Expand Down
13 changes: 11 additions & 2 deletions client_code/popover.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def handle_cleanup(self, **e):
@staticmethod
def document_sticky_mouseleave_handler(e):
# did we leave a popover?
target = e.target
target = _clean_target(e.target)
if not (target and target.hasAttribute("ae-popover")):
return

Expand Down Expand Up @@ -669,8 +669,17 @@ def get_all_parent_popover_ids(target):
return parent_ids


def _clean_target(target):
"""ensure we are dealing with a dom element and not a node"""
if not target:
return None
if target.nodeType != 1:
target = target.parentElement
return target


def _hide_popovers_on_outside_click(e):
target = e.target
target = _clean_target(e.target)
parent_ids = get_all_parent_popover_ids(target)

# Use a copy since the dict changes size during iteration
Expand Down

0 comments on commit d10418e

Please # to comment.