Last Comment Bug 818270 - Changing maxlength on an input with display: none doesn't change the maxlength
: Changing maxlength on an input with display: none doesn't change the maxlength
Status: NEW
:
Product: Core
Classification: Components
Component: Editor (show other bugs)
: 16 Branch
: x86 Mac OS X
: -- normal (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
Mentors:
http://dev-test.nemikor.com/bugs/fire...
Depends on:
Blocks: 895314 893614 910151
  Show dependency treegraph
 
Reported: 2012-12-04 14:09 PST by Scott González
Modified: 2014-08-15 03:59 PDT (History)
9 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---
-


Attachments

Description Scott González 2012-12-04 14:09:04 PST
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1

Steps to reproduce:

Set maxlength on an input that is hidden with display: none


Actual results:

The maxlength did not change.


Expected results:

The maxlength should change to the specified value.
Comment 1 Scott González 2012-12-04 14:11:41 PST
Originally reported against jQuery UI: http://bugs.jqueryui.com/ticket/8879

Our triage team says this was introduced in Firefox 4.
Comment 2 :Ehsan Akhgari (busy, don't ask for review please) 2012-12-04 14:41:38 PST
Yeah, unfortunately the maxlength enforcement is handled by the editor, which will not be around when the element doesn't have a frame attached to it...
Comment 3 Mounir Lamouri (:mounir) 2012-12-05 04:12:18 PST
(In reply to Ehsan Akhgari [:ehsan] from comment #2)
> Yeah, unfortunately the maxlength enforcement is handled by the editor,
> which will not be around when the element doesn't have a frame attached to
> it...

Ehsan, shouldn't nsTextEditorState.cpp take care of that? I would think that nsTextEditorState::PrepareEditor should set the maxlength on the editor.
Comment 4 Scott González 2012-12-05 05:37:45 PST
This looks like a bad reduction. Using elem.maxLength (capitalization) or elem.setAttribute( "maxlength", ... ) is working. I'll continue reducing the problem from the original jQuery UI report and figure out the actual case where this is failing.
Comment 5 Scott González 2012-12-05 05:47:14 PST
I've updated the linked test case. In order for the bug to occur the original maxlength and style must be set via JavaScript. The original test case set them directly in the markup, and the bug did not occur, it just appeared broken because of the incorrect casing on the property name.
Comment 6 :Ehsan Akhgari (busy, don't ask for review please) 2012-12-05 08:43:16 PST
(In reply to Mounir Lamouri (:mounir) from comment #3)
> (In reply to Ehsan Akhgari [:ehsan] from comment #2)
> > Yeah, unfortunately the maxlength enforcement is handled by the editor,
> > which will not be around when the element doesn't have a frame attached to
> > it...
> 
> Ehsan, shouldn't nsTextEditorState.cpp take care of that? I would think that
> nsTextEditorState::PrepareEditor should set the maxlength on the editor.

Yes, I think that would be the right fix.
Comment 7 Fernando R. Sela (no CC, needinfo please) [:frsela] 2013-07-17 05:44:39 PDT
Hi,

In my experiments, first time (if no maxlength is assigned), it works correctly.

If you try to update it (with display: none) it didn't work.

Fails using .maxLength but Using setAttribute works correctly.
Comment 8 Fernando R. Sela (no CC, needinfo please) [:frsela] 2013-07-18 01:48:29 PDT
(In reply to Fernando R. Sela [:frsela] from comment #7)
> Hi,
> 
> In my experiments, first time (if no maxlength is assigned), it works
> correctly.
> 
> If you try to update it (with display: none) it didn't work.
> 
> Fails using .maxLength but Using setAttribute works correctly.

Finally worked in my box but not on B2G18 :(
Comment 9 buri.blff 2013-09-12 19:00:38 PDT
the patch in 910151 is not ok;
set the input.maxlenth for the secend time, it' not ok;
Comment 10 buri.blff 2013-09-12 19:01:26 PDT
the pr 910151 is MNT pr;
Comment 11 buri.blff 2013-09-12 19:05:13 PDT
(In reply to Fernando R. Sela (no CC, needinfo please) [:frsela] from comment #7)
> Hi,
> 
> In my experiments, first time (if no maxlength is assigned), it works
> correctly.
> 
> If you try to update it (with display: none) it didn't work.
> 
> Fails using .maxLength but Using setAttribute works correctly.

Dear frsela:
   Does setAttribute will work correctly??
Comment 12 Fernando R. Sela (no CC, needinfo please) [:frsela] 2013-09-12 22:08:35 PDT
(In reply to buri.blff from comment #11)
> (In reply to Fernando R. Sela (no CC, needinfo please) [:frsela] from
> comment #7)
> > Hi,
> > 
> > In my experiments, first time (if no maxlength is assigned), it works
> > correctly.
> > 
> > If you try to update it (with display: none) it didn't work.
> > 
> > Fails using .maxLength but Using setAttribute works correctly.
> 
> Dear frsela:
>    Does setAttribute will work correctly??

As I told in comment #8, it worked in my box with firefox nightly >22 but not in B2G18 build so finally I added a Timeout in order to change it after the box is displayed.
Comment 13 buri.blff 2013-09-15 19:34:54 PDT
(In reply to Fernando R. Sela (no CC, needinfo please) [:frsela] from comment #12)
> (In reply to buri.blff from comment #11)
> > (In reply to Fernando R. Sela (no CC, needinfo please) [:frsela] from
> > comment #7)
> > > Hi,
> > > 
> > > In my experiments, first time (if no maxlength is assigned), it works
> > > correctly.
> > > 
> > > If you try to update it (with display: none) it didn't work.
> > > 
> > > Fails using .maxLength but Using setAttribute works correctly.
> > 
> > Dear frsela:
> >    Does setAttribute will work correctly??
> 
> As I told in comment #8, it worked in my box with firefox nightly >22 but
> not in B2G18 build so finally I added a Timeout in order to change it after
> the box is displayed.

we find the timeout patch is not ok for v1.1
Comment 14 Jason Smith [:jsmith] 2013-09-17 16:08:50 PDT
Not blocking - we've shipped multiple platforms with this bug already and the blocking bug had a workaround implemented to get around this issue.
Comment 15 buri.blff 2013-09-20 18:11:38 PDT
(In reply to Jason Smith [:jsmith] from comment #14)
> Not blocking - we've shipped multiple platforms with this bug already and
> the blocking bug had a workaround implemented to get around this issue.

Jason Smith:
   can you tell me how to workaround this pr?
Comment 16 buri.blff 2013-09-25 01:56:20 PDT
(In reply to Jason Smith [:jsmith] from comment #14)
> Not blocking - we've shipped multiple platforms with this bug already and
> the blocking bug had a workaround implemented to get around this issue.

we don't find this pr in v1.0.1
Comment 17 bucabug 2014-01-03 00:56:12 PST
It appears this issue was first reported years ago here:

https://bugzilla.mozilla.org/show_bug.cgi?id=350786

I'm still experiencing this issue in Firefox 26.0 

Forgive my ignorance as this is the first issue I've been involved with with Firefox  - I see that is bug is set to NEW however there has been talk of a proposed workaround.

What is the state of this issue - is there a solution that has not yet been released or is there no known solution?
Comment 18 Josh Matthews [:jdm] 2014-01-03 06:58:58 PST
A potential solution is proposed in comment 6, but nobody has implemented it yet. If you or a friend have C++ experience, feel free to give it a try: https://developer.mozilla.org/en/Simple_Firefox_build
Comment 19 Marco 2014-08-14 03:11:24 PDT
The behavior is very strange.

If i try to set a value for maxlenght when display is "none", maxlenght doesn't change and I can't set the same value.

The code:  

    <input id="t1" type="text" display="inline-block"><p id="t2">max: 20</p>
    <input id="b1" type="button" name="b1" value="2" onclick="document.getElementById('t1').setAttribute('maxlength','2'); document.getElementById('t2').innerHTML='max: 2'">
    <input id="b2" type="button" name="b2" value="3" onclick="document.getElementById('t1').setAttribute('maxlength','3'); document.getElementById('t2').innerHTML='max: 3'">
    <input id="b3" type="button" name="b3" value="4" onclick="document.getElementById('t1').setAttribute('maxlength','4'); document.getElementById('t2').innerHTML='max: 4'">
    <input id="b4" type="button" name="b4" value="able" onclick="var el = document.getElementById('t1'); (el.style.display=='none')? el.style.display='inline-block' : el.style.display='none';">

The test:

a) press 2(p2), disable, p3, enable (maxlenght is 2 yet!), p3 (maxlenght is 2 yet!), p4 (maxlenght is 4 now)
b) press 2(p2), disable, p3, enable (maxlenght is 2 yet!), p4 (maxlenght is 4 now), p3 (maxlenght is 3 now)
Comment 20 Marco 2014-08-15 03:59:48 PDT
> If i try to set a value for maxlenght when display is "none", maxlenght
> doesn't change and I can't set the same value.
When the textbox is get back visible, i can't set the same value i tried to set when display was none (test a).

Note You need to log in before you can comment on or make changes to this bug.