Suggestion to add a “close button” in the popup window

When a search window pops up in the search app, there is no close button, so I have to click on the outside of the popup window to make it disappear. So it would be handy to have a close button.

2 Likes

Happy to see you on our forum! Welcome, @Teo_Chung :wave:

I agree that it would be awesome to have this option as a widget’s setting. We’ll try to consider this opportunity in the future, especially if more users upvote it :slightly_smiling_face:

As for now, we’ll be happy to create a custom close button for you. Would you like to have it as a simple cross icon?

Yes, A simple cross icon is fine.

1 Like

Okay, I’ve passed this idea on to the devs. I’ll report back once the solution is ready :slightly_smiling_face:

Please add this code to the Custom CSS field on the Settings tab of your widget’s settings:

.global-styles,
[class*='Popup__Container-sc']::after {
  content: '\00d7';
  font-size: 24px;
  line-height: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(17, 17, 17, 0.1);
  font-weight: bold;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
}

And this script should be added to the Custom JS field on the Settings tab:

document.addEventListener("click", ({ target, clientX, clientY }) => {
  const popup = target.closest("[class*='Popup__Container-sc']");
  
  if (popup) {
    return;
  }
  
  const rect = popup.getBoundingClientRect();
  
  const afterRight = rect.right - 5;
  const afterLeft = afterRight - 24;
  const afterTop = rect.top + 5;
  const afterBottom = afterTop + 24;
  
  if (
    clientX >= afterLeft && 
    clientX <= afterRight && 
    clientY >= afterTop && 
    clientY <= afterBottom
  ) {
    document.body.click();
  }
});

Try it out and let me know if you like the result

1 Like

Thanks for the custom code, but I tested it after applying it and the close button doesn’t work.

1 Like

Could you please send me a link to the page, where your widget is installed?

autobritedirect.co.kr

1 Like

We’ve adjusted the codes and added them to your widgets.

Custom JS:

document.addEventListener("click", ({ target, clientX, clientY }) => {
  const popup = target.closest("[class*='Popup__Container-sc']");
  
  if (!popup) {
    return;
  }
  
  const rect = popup.getBoundingClientRect();
  
  const afterRight = rect.right - 5;
  const afterLeft = afterRight - 24;
  const afterTop = rect.top + 5;
  const afterBottom = afterTop + 24;
  
  if (
    clientX >= afterLeft && 
    clientX <= afterRight && 
    clientY >= afterTop && 
    clientY <= afterBottom
  ) {
    document.body.click();
  }
});

Custom CSS:

.global-styles,
[class*='Popup__Container-sc']::after {
  content: '\00d7';
  font-size: 24px;
  line-height: 18px;
  display: flex;
  justify-content: center;
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(17, 17, 17, 0.1);
  font-weight: bold;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
}

Please check your website and let me know if you like the result :slightly_smiling_face:

1 Like

It works!!!

1 Like