Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    IE8 bug for TextAreaItem.getSelectionRange()

    IE 8 only bug (all the rest work as expected) for gwt 3.1.
    I believe the IE8 lost the "\r\n" during counting.

    Here's the code, which I created to demonstrate the bug:
    Code:
     
    DynamicForm form = new DynamicForm();
            
            final TextAreaItem txt = new TextAreaItem("test");
            txt.setValue("1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11"); 
            txt.addClickHandler( new com.smartgwt.client.widgets.form.fields.events.ClickHandler(){
    
    		
    			@Override
    			public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
    				Object source = event.getSource();
    				if(source instanceof TextAreaItem) {
    					TextAreaItem text = (TextAreaItem)source;
    					int range[] = text.getSelectionRange();
    					SC.say("Txt Range is " + range[0] + ":" + range[1]);
    					String str = (String)text.getValue();
    					str = str.substring(0, range[0]) + "A" + str.substring(range[1]);
    					text.setValue(str);
    					
    				}
    			}
            	
            });
            
            form.setFields(txt);
    In all browsers this code prints "A" on the place you clicked inside the TextAreaitem. In IE8 it somehow loses "\r\n" - all of them in front of your click. For example if you click after "7" - the "A" is inserted after "5".

    #2
    I've found how to fix it for IE8 only, but still think it's the gwt bug.
    here's my fix:
    Code:
    //add the end-of-line chars
    								//this is bug in IE8 only - it skips EOL chars - add it on our own
    								final String eol = "\r\n";
    								final String frontText = currText.substring( 0, selRange[0] );
    								final String delimeteredFrontString[] = frontText.split(eol);
    								int numberOfEOL = delimeteredFrontString.length;
    								if ( numberOfEOL > 1 ) { //if it's just 1 line - do nothing - no EOL were found
    									--numberOfEOL;
    									selRange[0] += numberOfEOL;
    									selRange[1] += numberOfEOL;
    								}
    now you can use the newly updated selRange for substrings

    Comment


      #3
      Thanks for the notification. Good to see you have a workaround.
      We've also assigned the underlying issue to a developer for investigation.

      Regards
      Isomorphic Software

      Comment


        #4
        And just to follow up, we have made a change to address this issue. Please try the next nightly build dated July 25 to pick up the change

        Regards
        Isomorphic Software

        Comment

        Working...
        X