Closed Bug 303382 Opened 21 years ago Closed 19 years ago

Using input element inside a label element -> focus for input element gets lost when you click in it

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 213519

People

(Reporter: s.stock, Unassigned)

Details

(Keywords: testcase)

Attachments

(2 files)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b3) Gecko/20050712 Firefox/1.0+ Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b3) Gecko/20050712 Firefox/1.0+ I am using an input element inside an label element which is linked with an radio button. When I click on the input element the focus is set to the radio button - not to the input element. So I can't enter any values. Reproducible: Always Steps to Reproduce: 1.open attached example 2.click on the input element 3. Actual Results: focus is set to radio button Expected Results: focus should be set to input element
Attached file bug showcase —
The label has attribute for="IsAvailableDate", so the focus goes to the form element with that id, which happens to be the radio button. When you remove that for attribute, everything should work ok.
Yes this works, but I want the radio button to be "checked" when I click into the input element. Anyway I expected the focus to stay on the input element. Maybe it's not a bug but a feature wish... I used some JavaScript to get this behavior and this is ok for me.
No, when you use the for attribute, the focus is shifted to the associated element: http://www.w3.org/TR/html401/interact/forms.html#h-17.9.1 "When a LABEL element receives focus, it passes the focus on to its associated control. See the section below on access keys for examples." So, you'll going to have to use javascript.
Snippet of HTML code from Collegeboard.com which produces the bug. Clicking inside the input element moves focus to the radio button and makes it (nearly) impossible to type in the input (text) box.
May be a Gecko bug? Confirmed in both Windows 2000 and Windows XP Pro SP2. This should be labeled as a MAJOR bug, because when it shows up, it's serious. Even though it's technically, and arguably, the fault of whosever HTML it was.
Confirmed in Win XP - Firefox 1.5Beta1
Summary: Using input element inside a label element -> focus for input element gets lost when you click on it → Using input element inside a label element -> focus for input element gets lost when you click in it
i can reproduce this bug with the testcase on Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9a6pre) Gecko/2007060704 Minefield/3.0a6pre - so confirmed
Status: UNCONFIRMED → NEW
Component: General → Event Handling
Ever confirmed: true
Keywords: testcase
Product: Firefox → Core
QA Contact: general → events
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → DUPLICATE
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: