Re: [w3c/uievents] Should an element remain focused and receive key events if it's display:none-ed? (#236)

```html
<!DOCTYPE html>
<html>
<body>
<pre id="log"></pre>
<script>

onload = () => {
    const input = document.createElement('input');
    document.body.appendChild(input);
    input.focus();
    input.addEventListener('blur', () => log.textContent += 'blur');
    input.style.display = 'none';
    document.body.getBoundingClientRect();
    input.style.display = null;
}

</script>
</body>
</html>
```

Doesn't log blur in Chrome regardless of `document.body.getBoundingClientRect()` is executed or not so this seems to indicate that Chrome is indeed waiting for some time to decide whether the element has become invisible or not. The following example also seems to always logs blur and this is problematic because it implies that we'd have to resolve the style after each task. We don't want to do that.

```html
<!DOCTYPE html>
<html>
<body>
<pre id="log"></pre>
<script>

onload = () => {
    const input = document.createElement('input');
    document.body.appendChild(input);
    input.focus();
    input.addEventListener('blur', () => log.textContent += 'blur');
    input.style.display = 'none';
    setTimeout(() => {
        input.style.display = null;
    }, 0);
}

</script>
</body>
</html>

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/uievents/issues/236#issuecomment-507362930

Received on Monday, 1 July 2019 17:53:28 UTC