Closed Bug 300875 Opened 16 years ago Closed 15 years ago

textbox with elements inside can only receive focus if its type is set to autocomplete

Categories

(Core :: XUL, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.8.1beta1

People

(Reporter: Felipe, Assigned: martijn.martijn)

References

()

Details

(Keywords: fixed1.8.1)

Attachments

(1 file, 2 obsolete files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3

A <textbox> with an <image> or a <button> element (and possibly others too)
doesn't receive focus, and therefore text can't be entered on it, and it doesn't
display its default text set by 'value="some text"'.
Interestingly, everything works correctly if the textbox type is set to
autocomplete.

Example:

<textbox id="foo" value="Some text here"><button label="Press me!" /></textbox>

^  doesn't work

<textbox id="foo" value="Some text here" type="autocomplete"><button
label="Press me!" /></textbox>

^ work

I could add an image using css styles, but using the <image> element inside the
textbox is the way that both the location bar and the search bar is structured
in Firefox.  Also, using css would solve the problem for the image, but not for
a button.

Another thing that happens with the weird textbox is that if the image is not
loaded, its heigth is set to a minimum.. probably 3 or 4 pixels only..

This has been tested in Firefox 1.0.3, 1.0.4, 1.0.5 and deer park alpha 1 and 2.

Reproducible: Always

Steps to Reproduce:
1. Open up the example URL
2. Try to type in the textbox
3. You can't!

Actual Results:  
Nothing happens! you can't type at all, and can't view any text that is already
inside it.

Expected Results:  
It should work in the same way as the textbox with type="autocomplete"
Invalid? Textbox should be an empty element.

You should use CSS to add presentation image to your textboxs.
Hi,

As I described, this is not only for <image>s, but also for other elements as well.

The xulplanet's element reference doesn't say anything against elements inside a
textbox.

Using an <image> inside the <textbox> is the way that the Location Bar and
Search Bar is built in Firefox, so I think there is no problem in adding
elements inside textboxes.
Maybe it is made this way because the CSS styling in textboxes are somewhat
problematic (see July 11, 2005 "user contributed note" here:
http://xulplanet.com/references/elemref/ref_textbox.html), because the textbox
actually wraps a HTML input element.


Simply adding the type="autocomplete" in the textbox makes it work perfectly as
expected, so I still think there is a problem with it.
textbox type="autocomplete" gets this binding:
http://lxr.mozilla.org/seamonkey/source/toolkit/content/widgets/autocomplete.xml#48

A 'normal' textbox gets this binding:
http://lxr.mozilla.org/seamonkey/source/toolkit/content/widgets/textbox.xml#14

If I remember it correctly, there was a bug where a binding is not applied (or
the content part of it) when the <children/> tag is missing inside the <content/>.

So this could be fixed by adding the <children/> tag inside the <content>.
Attached patch patch (obsolete) — Splinter Review
Yes, that works.
I've put the <children/> at the beginning. That seems to me consistent with the
autocomplete binding.
Attachment #189823 - Flags: review?(neil.parkwaycc.co.uk)
Comment on attachment 189823 [details] [diff] [review]
patch

Did you mean for the textbox context menu to apply to the children?
Attachment #189823 - Flags: review?(neil.parkwaycc.co.uk)
Attached patch patch2 (obsolete) — Splinter Review
Well, not really. You're probably right, it's better to put the children
outside.
Attachment #189823 - Attachment is obsolete: true
Attachment #189849 - Flags: review?(neil.parkwaycc.co.uk)
Comment on attachment 189849 [details] [diff] [review]
patch2

>-    <content>
>+    <content><children/>
>       <xul:hbox class="textbox-input-box" flex="1" xbl:inherits="context">

<content>
  <children/>
  <xul:hbox ...>
Attached patch patch3Splinter Review
Sure, done.
I guess this needs review from xpfe and toolkit reviewers, right?
Attachment #189849 - Attachment is obsolete: true
Attachment #189849 - Flags: review?(neil.parkwaycc.co.uk)
Attachment #189906 - Flags: review?(neil.parkwaycc.co.uk)
Assignee: nobody → martijn.martijn
Attachment #189906 - Flags: superreview+
Attachment #189906 - Flags: review?(neil.parkwaycc.co.uk)
Attachment #189906 - Flags: review?(mconnor)
Status: UNCONFIRMED → NEW
Ever confirmed: true
Hi,

Any chances of this being fixed for FF 1.5 ?  It seems that it is a simple bug just waiting to be commited, and having it fixed in this major release would be great, since there are many improvements on XUL and these kind of features in FF 1.5 which improves the way FF can be used as an application platform.

Felipe
Attachment #189906 - Flags: review?(mconnor) → review?(bugs.mano)
Comment on attachment 189906 [details] [diff] [review]
patch3

r+a181=mano on the toolkit part, asking neil for approval-seamonkey.
Attachment #189906 - Flags: review?(bugs.mano)
Attachment #189906 - Flags: review+
Attachment #189906 - Flags: approval-branch-1.8.1?(neil)
Attachment #189906 - Flags: approval-branch-1.8.1?(neil) → approval-branch-1.8.1+
Flags: blocking1.8.1?
Target Milestone: --- → mozilla1.8.1beta2
OS: Windows XP → All
Hardware: PC → All
Target Milestone: mozilla1.8.1beta2 → mozilla1.8.1beta1
Checking in toolkit/content/widgets/textbox.xml;
/cvsroot/mozilla/toolkit/content/widgets/textbox.xml,v  <--  textbox.xml
new revision: 1.32; previous revision: 1.31
done
Checking in xpfe/global/resources/content/bindings/textbox.xml;
/cvsroot/mozilla/xpfe/global/resources/content/bindings/textbox.xml,v  <--  text
box.xml
new revision: 1.41; previous revision: 1.40
done

Fixed on trunk.

Checking in toolkit/content/widgets/textbox.xml;
/cvsroot/mozilla/toolkit/content/widgets/textbox.xml,v  <--  textbox.xml
new revision: 1.21.12.1; previous revision: 1.21
done
Checking in xpfe/global/resources/content/bindings/textbox.xml;
/cvsroot/mozilla/xpfe/global/resources/content/bindings/textbox.xml,v  <--  text
box.xml
new revision: 1.32.12.1; previous revision: 1.32
done

Fixed on 1.8.1 branch.
Status: NEW → RESOLVED
Closed: 15 years ago
Keywords: fixed1.8.1
Resolution: --- → FIXED
this didn't appear on the branch tinderbox (did no land) Martijn
Ok, apparently I'm doing something wrong here :(
I need to ask someone.
Keywords: fixed1.8.1
Checking in xpfe/global/resources/content/bindings/textbox.xml;
/cvsroot/mozilla/xpfe/global/resources/content/bindings/textbox.xml,v  <--  text
box.xml
new revision: 1.32.4.4; previous revision: 1.32.4.3
done

Finally checked into the 1.8.1 branch.
Keywords: fixed1.8.1
Component: XP Toolkit/Widgets: XUL → XUL
QA Contact: xptoolkit.xul → xptoolkit.widgets
You need to log in before you can comment on or make changes to this bug.