Skip to content

Commit

Permalink
close autocomplete on click in parent window
Browse files Browse the repository at this point in the history
  • Loading branch information
Yen Truong committed Jan 14, 2022
1 parent 92290c8 commit cfa4adc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions layouts/html.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@
HitchhikerJS.RuntimeConfigReceiver.handle(message.runtimeConfig);
} else if (window.isOverlay) {
window.Overlay.onMessage(message);
} else if (message.eventType && message.eventType === 'click') {
ANSWERS.components._activeComponents
.filter(component => component.name === 'SearchBar.autocomplete')
.forEach(autocompleteComponent => autocompleteComponent.close());
}
}
};
Expand Down
7 changes: 7 additions & 0 deletions static/js/iframe-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ export function generateIFrame(domain, answersExperienceFrame) {

containerEl.appendChild(iframe);

// Notify iframe of a click event on parent window
document.addEventListener('click', e => {
if (e.isTrusted) {
sendToIframe({ eventType: e.type });
}
});

// For dynamic iFrame resizing
iFrameResize({
checkOrigin: false,
Expand Down

0 comments on commit cfa4adc

Please sign in to comment.