Floating WebView doesn't work in latest version if you have 'Close when clicking outside' activated

Describe the bug
If you have a Fkloating WebView with 'Close when clicking outside' enabled the WebView seems to disappear before it is rendered (if you have 'Show Window buttons' checked) you can see the window buttons momentarily before they disappear)

Affected input device (e.g. MacBook Trackpad, Magic Mouse/Trackpad, Touch Bar, etc.):
I have a global named trigger that brings up my WebView, then multiple triggers that call this. Magic mouse tiptap, trackpad tiptap and a keyboard shortcut. Whatever I use to trigger it, it disappears before it renders. Doesn't matter if it's complex HTML file or a very simple "Hello world!" typed into the direct HTML field. This was working flawlessly before the most recent update, and also works as expected if you don't have "Close when clicking outside enabled".

Device information:

  • Type of Mac: MacBook Pro (15", 2016)
  • macOS version: 10.13.4
  • BetterTouchTool version: 2.512

Hi,

I have tested it with my setup and it was only occurring one just after the update of the content of the webview.
Was working nicely the second time I trigger the view.

Cheers,

Olivier

It might have something to do with the "Do NOT cache" option on the WebView. If I disable this option it seems to do as you say Olivier (i.e. fails on the first view, but then succeeds on subsequent). I had this on previously as I was making changes to the HTML it was rendering.

Having this option enabled WAS working before the update. Now, if it's on, the render doesn't happen at all, and with it off seems to fail on the first attempt, then works on subsequent.

Hope this helps track down the issue.

Thanks for reporting! Could you check v2.513?

Work for me thanks!

Olivier

Thanks Andreas. It's now working again in 2.513.

Much appreciated.

I have updated to 2.513, but it only works one time after relaunch BTT.

In that case it may also be a problem with your HTML/JS, could you provide it here?

function BTTWillCloseWindow() {
var script = document.createElement("script");
script.innerHTML = "function BTTInitialize() {window.location = 'file:///***/hehe.html'}";
document.head.appendChild(script);
var e = document.body;
e.parentNode.removeChild(e);
}
document.addEventListener('keydown', (event) => {
const keyName = event.key;
console.log(keyName)
if (keyName === 'Escape') {
// do not alert only when Control key is pressed.
fetch("http://127.0.0.1:52990/trigger_action/?closeFloatingHTMLMenu=1");
}
}, false);

function copyToClipboard(text){
var dummy = document.createElement("input");
document.body.appendChild(dummy);
dummy.setAttribute('value', text);
dummy.select();
document.execCommand("copy");
document.body.removeChild(dummy);
}
$('#result').on('click', 'a', function(e) {
var href = $(this).attr('href');
if (href && href.substring(0, 8) === 'entry://') {
e.preventDefault();
console.log(90)
var word = href.substring(8);
if (word.charAt(0) !== '#') {
word = word.replace(/(^[/\])|([/]$)/, '');
copyToClipboard(word);
fetch("http://127.0.0.1:52990/execute_assigned_actions_for_trigger/?uuid=******")
.then(response => setTimeout(()=>{window.location.reload()}, 200))
} else {
var currentUrl = location.href;
location.href = word;
}
}
})

Mh what is redirect for, that you are doing in the BTTInitialize function? (the one which you are adding in the BTTWillCloseWindow function) I think this might be problematic.

I use this redirect to refresh the page, since old version did not have the option "Do NOT cache this menu". After this option is available and before v2.512, this float webview worked.

I just checked "Do NOT cache this menu", and this float webview always works well when I remain or comment the redirect in the script.