Skip to content

Commit 891696a

Browse files
authored
Skip phx-click-away if clicked target is hidden (#4077)
Closes #4070.
1 parent c8d9357 commit 891696a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

assets/js/phoenix_live_view/live_socket.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,17 @@ export default class LiveSocket {
868868
dispatchClickAway(e, clickStartedAt) {
869869
const phxClickAway = this.binding("click-away");
870870
DOM.all(document, `[${phxClickAway}]`, (el) => {
871-
if (!(el.isSameNode(clickStartedAt) || el.contains(clickStartedAt))) {
871+
if (
872+
!(
873+
el.isSameNode(clickStartedAt) ||
874+
el.contains(clickStartedAt) ||
875+
// When clicking a link with custom method,
876+
// phoenix_html triggers a click on a submit button
877+
// of a hidden form appended to the body. For such cases
878+
// where the clicked target is hidden, we skip click-away.
879+
!JS.isVisible(clickStartedAt)
880+
)
881+
) {
872882
this.withinOwners(el, (view) => {
873883
const phxEvent = el.getAttribute(phxClickAway);
874884
if (JS.isVisible(el) && JS.isInViewport(el)) {

0 commit comments

Comments
 (0)