dhamaso / ufd

Automatically exported from code.google.com/p/ufd
GNU General Public License v2.0
0 stars 0 forks source link

pre-selected option in plain drop-down is NOT correctly pre-selected if using UFD #50

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Make a page with a drop down, mark one of the options with 
selected="selected"
2. Load the page 
3. click on the drop-down arrow on the combo box.

For example, take the index.html file that is provided with the UFD samples, 
and pre-select "Bahrain"

What is the expected output? 
- normal behaviour for a combobox is that the 'selected' item is clearly 
selected in the list, not just displayed in the text box.

What do you see instead?
- UFD enabled combox boxes show the first value as the selected option in the 
drop-down, although the text in the text box is correct.

On my more elaborate page that automatically submits in the onchange event of 
the control, the result is that if I click off the drop-down, the selection is 
changed to the first element - which is '-- Select One --', which therefore 
clears the page.

What version of the product are you using? On what operating system?
- UFD 0.6, 0.5
- Windows XP
- FF 5.0 beta
- FF 4
- IE 7

Please provide any additional information below.
Great looking control so far - this is really the only hang-up I've having!

Original issue reported on code.google.com by aru...@anm.org on 8 Jun 2011 at 10:52

GoogleCodeExporter commented 9 years ago
same happens on IE 8

Original comment by aru...@anm.org on 8 Jun 2011 at 11:32

GoogleCodeExporter commented 9 years ago
OK, I seem to have addressed the problem.  The change was to 
_populateFromMaster: function()

replace:

        while(loopCountdown--) {
            thisOpt = options[index];           
            self.trie.add( $.trim(thisOpt.text), theLiSet[index++]); //option.text not innerHTML for trie as we dont want escaping

        } 

with: 

        while(loopCountdown--) {
            thisOpt = options[index];
            if (thisOpt.selected)
                this.selectedLi = theLiSet[index];
            self.trie.add( $.trim(thisOpt.text), theLiSet[index++]); //option.text not innerHTML for trie as we dont want escaping

        } 

AND comment out the setting of the selectedLi after calling setInputFromMaster

this.visibleCount = theLiSet.length;
this.setInputFromMaster();
//this.selectedLi = null;

=================

This may not be the _best_ way of solving the problem, but currently the 
behaviour appears to be closer to what I expect.

Original comment by aru...@anm.org on 9 Jun 2011 at 12:15

GoogleCodeExporter commented 9 years ago
Yes this is not good!

Original comment by thetoolman on 4 Oct 2011 at 11:39

GoogleCodeExporter commented 9 years ago

Original comment by thetoolman on 5 Oct 2011 at 10:41

GoogleCodeExporter commented 9 years ago
See http://code.google.com/p/ufd/source/detail?r=264 fix included in trunk and 
next release.

Original comment by thetoolman on 5 Oct 2011 at 10:42