Merge pull request #13645 from calixteman/bug1718241
XFA - Choice list has no selected value by default (bug 1718241)
This commit is contained in:
		
						commit
						f35e4cc9ab
					
				@ -1046,6 +1046,7 @@ class ChoiceList extends XFAObject {
 | 
			
		||||
      const displayed = items.children[displayedIndex][$toHTML]().html;
 | 
			
		||||
      const values = items.children[saveIndex][$toHTML]().html;
 | 
			
		||||
 | 
			
		||||
      let selected = false;
 | 
			
		||||
      const value = (field.value && field.value[$text]()) || "";
 | 
			
		||||
      for (let i = 0, ii = displayed.length; i < ii; i++) {
 | 
			
		||||
        const option = {
 | 
			
		||||
@ -1056,10 +1057,21 @@ class ChoiceList extends XFAObject {
 | 
			
		||||
          value: displayed[i],
 | 
			
		||||
        };
 | 
			
		||||
        if (values[i] === value) {
 | 
			
		||||
          option.attributes.selected = true;
 | 
			
		||||
          option.attributes.selected = selected = true;
 | 
			
		||||
        }
 | 
			
		||||
        children.push(option);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (!selected) {
 | 
			
		||||
        children.splice(0, 0, {
 | 
			
		||||
          name: "option",
 | 
			
		||||
          attributes: {
 | 
			
		||||
            hidden: true,
 | 
			
		||||
            selected: true,
 | 
			
		||||
          },
 | 
			
		||||
          value: " ",
 | 
			
		||||
        });
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const selectAttributes = {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user