If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Listbox fails to retain the visibly selected position when the text value of the selected element is modified within a set of N elements where N > SIZE property >0 and the selectedIndex value > SIZE.

VERIFIED DUPLICATE of bug 273681

Status

()

Firefox
General
VERIFIED DUPLICATE of bug 273681
13 years ago
13 years ago

People

(Reporter: arsukdeo, Assigned: Blake Ross)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

13 years ago
User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8a6) Gecko/20041207 Firefox/1.0+

Having a list box with the property SIZE>0, and having N elements greater than 
the SIZE value, and the users scrolls down the list to select an element at the 
(SIZE+1) position, then if a bit of code executes on the form to modify the 
text value of the selected element, the list box scrolls back to the top SIZE 
viewable elements.


Reproducible: Always
Steps to Reproduce:
<HTML>
<TITLE>Firefox Test Case from TECHNOCORP</TITLE>
<SCRIPT type="text/javascript">
function setPos()
   {
   var obj = document.frmObj;
   var pos = obj.m_select.selectedIndex;
   obj.m_text.value = pos;
   if (obj.m_select.length > 0)
      {
      if (obj.m_select.selectedIndex > 0)
         {
         obj.m_select.selectedIndex = 0;   
         obj.m_select.selectedIndex = pos;
         }
      else
         obj.m_select.selectedIndex = 0;
      }
   }

function doScroll()
   {
   var obj = document.frmObj;
   var pos = obj.m_select.selectedIndex;
   if (obj.m_select && obj.m_select.length > 0)
      {
      obj.m_select.selectedIndex = 0;
      obj.m_select.selectedIndex = pos;
      alert("Position rescrolled before element modification.");
      obj.m_select.options[pos].text = obj.m_select.options[pos].text + " - 
tag";
      alert("Element modified.");
      alert("Current selection position: "+ obj.m_select.selectedIndex+".");
      obj.m_text.value = obj.m_select.selectedIndex;
      }
   }


</SCRIPT>
<BODY>
<FORM NAME=frmObj>
<TABLE BORDER=1 style=width:400px">
<TR><TD COLSPAN=2>Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8a6) 
Gecko/20041207 Firefox/1.0+</TD></TR>
<TR><TD COLSPAN=2>
1.  Scroll down to any element after the 2nd element.<BR>
2.  Select the element.<BR>
3.  Click the Re-Scroll button to see bug.<BR>
    Note that the selected item was modifed, and did retain the "selectedIndex" 
property value. &nbsp;
    But the modification appears to trigger an event that scrolls the listbox 
to the first element.
</TD>
</TR>
<TR><TD>
<SELECT SIZE=2 NAME=m_select onClick="setPos()">
<OPTION>A</OPTION>
<OPTION>B</OPTION>
<OPTION>C</OPTION>
<OPTION>D</OPTION>
<OPTION>E</OPTION>
<OPTION>F</OPTION>
<OPTION>G</OPTION>
<OPTION>H</OPTION>
<OPTION>I</OPTION>
<OPTION>J</OPTION>
<OPTION>K</OPTION>
<OPTION>L</OPTION>
<OPTION>M</OPTION>
<OPTION>N</OPTION>
</SELECT>
</TD>
<TD><INPUT TYPE=BUTTON VALUE="Re-Scroll" onClick="doScroll()"></TD>
</TR>
<TR><TD COLSPAN=3>Report Position:<INPUT TYPE=TEXT NAME=m_text 
VALUE=""></TD></TR>
</TABLE>
</FORM>
</BODY>
</HTML>

Actual Results:  
The listbox fails to maintain the visibility of the selected element at 
the "selectedIndex" position after the text value of the selected element is 
modified.


Expected Results:  
If a bit of code scrolls the listbox, by using the "selectedIndex" property, 
subsequent changes to the TEXT value of the selected element should not cause 
the listbox to (scroll up and) display the first SIZE number of elements.


This bug also exists in the latest Mozilla build, and was reported under 
bug#273681.  

It is not a major bug in the behaviour of the listbox, because the workaround 
for a simple implementation involves modifying the "text" value first before 
calling any code to scroll the listbox on the "selectedIndex" property.  
However, for more complex implementations with listboxes, where it is not 
possible to do this, one has to call a timed event/subroutine/handle to do the 
scrolling, which results in a slight quirky/slow behaviour of the browser to 
the ordinary user.  I hope this bug can be fixed in the next major release of  
Firefox.

Comment 1

13 years ago
(In reply to comment #0)
> This bug also exists in the latest Mozilla build, and was reported under 
> bug#273681.  

It doesn't need to be reported again as a FF bug then.

*** This bug has been marked as a duplicate of 273681 ***
Status: UNCONFIRMED → RESOLVED
Last Resolved: 13 years ago
Resolution: --- → DUPLICATE

Comment 2

13 years ago
v
Status: RESOLVED → VERIFIED

Comment 3

13 years ago
hi

i cannot get the following code working. Firefox isn't scrolling down in the
listbox! the reporters comment about a workaround isn't working! 

var moveText1 = document.getElementById(listField)[selected+1].text;
var moveValue1 = document.getElementById(listField)[selected+1].value;
var moveText2 = document.getElementById(listField)[selected].text;
var moveValue2 = document.getElementById(listField)[selected].value;
document.getElementById(listField)[selected].text = moveText1;
document.getElementById(listField)[selected].value = moveValue1;
document.getElementById(listField)[selected+1].text = moveText2;
document.getElementById(listField)[selected+1].value = moveValue2;
document.getElementById(listField).selectedIndex = selected+1; // Select the one
that was selected before


please fix this in next release!
You need to log in before you can comment on or make changes to this bug.