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

Consider a page with the following markup:
```
<!DOCTYPE html>
<html>
<style>
.collapse {
    display: none;
}
</style>
<body>
<p>This page focuses a text field, then hides the field by display:none-ing its containing block after one second.</p>
<div id="test">
    <input id="input" type="text" onblur="logMessage('field blur')" onfocus="logMessage('field focus')" onkeydown="logMessage('field keydown')">
</div>
<pre id="console"></pre>
<script>
function runTest()
{
    document.getElementById("test").classList.remove("collapse");
    document.getElementById("input").focus();

    window.setTimeout(() => {
        document.getElementById("test").classList.add("collapse");
    }, 1000);
}

function logMessage(message)
{
    document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
}

runTest();
</script>
</body>
</html>
```

Load the page, wait one second. What events do you see printed? In Safari on macOS Mojave and Firefox for Mac 67.0.4 I see:
```
field focus
```
In Chrome for Mac version 75.0.3770.100 and Chrome Canary for Mac version 77.0.3835.0 I see, emphasis mine:
```
field focus
**field blur**
```

**So, should a blur event be fired?**

So that was the most important question. Many things fall out from the answer to that question. Just to give a sample of things that fall out try this: press a key, like 'a'. Then in Safari I see, emphasis mine:

```
field focus
**field keydown**
```

Both Firefox and Chrome **don't** fire such keydowns. But remember, Firefox **never** fired a blur event (above) so the field is still focused? So it should get key events?

The spec does not seem to specify what the behavior should be when an element's display property is changed to "none". Can we please get some spec. text for this?

-- 
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

Received on Thursday, 27 June 2019 22:08:21 UTC