Closed
Bug 1468049
Opened 7 years ago
Closed 5 years ago
label can't be focused by element.focus
Categories
(Core :: DOM: UI Events & Focus Handling, defect, P3)
Tracking
()
RESOLVED
DUPLICATE
of bug 1240285
People
(Reporter: xianshenglu, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36
Steps to reproduce:
Demo: https://codepen.io/xianshenglu/pen/gKgPpN
Code:
```html
<label id="cont" contentEditable>
label should be focused
</label>
<button id="focus">make label focus</button>
```
```css
#cont {
display: block;
background:pink;
width:150px;
height:40px;
}
```
```javascript
$("#focus")[0].onclick=() => {
$("#cont")[0].focus();
};
$("#cont")[0].onfocus=(event) => {
console.log(event.type);
};
function $ (selector){
return Array.from(document.querySelectorAll(selector))
}
```
After loaded, please press F12 and open the console and then press the button.
Actual results:
label#cont isn't focused after pressing the button. So, there is nothing at the console.
Expected results:
label#cont should be focused after pressing the button.So, there will be word `focus` at the console. Because:
1. You can focus it by click
2. Chrome will focus
3. I don't see why can't focus because there is no input element if it matters.
Comment 1•7 years ago
|
||
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0 (20180611100116)
I have tested this report on Windows 10 x64 using latest Nightly, Beta 61.0b13, and Firefox release. I'm able to reproduce the issue on all tested versions. When pressing the button the label is not focused as it is in Chrome and there is no error/warning in the console.
Based on other reports I think the right component would be Core::Layout:Form Controls. Please change if this is not the correct component.
Status: UNCONFIRMED → NEW
status-firefox60:
--- → affected
status-firefox61:
--- → affected
status-firefox62:
--- → affected
Component: Untriaged → Layout: Form Controls
Ever confirmed: true
Product: Firefox → Core
Updated•6 years ago
|
Component: Layout: Form Controls → DOM: Core & HTML
Comment 2•5 years ago
|
||
Label is now correctly focused.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
Updated•5 years ago
|
Component: DOM: Core & HTML → DOM: UI Events & Focus Handling
You need to log in
before you can comment on or make changes to this bug.
Description
•