Opened 13 years ago

Closed 13 years ago

#5580 closed defect (fixed)

InlineEditbox renderAsHtml logical error when set to true using textareas

Reported by: guest Owned by:
Priority: high Milestone: 1.1
Component: Dijit Version: 1.0
Keywords: inlineeditbox renderashtml Cc:
Blocked By: Blocking:

Description (last modified by bill)

In InlineEditBox?.js at line 129 the renderAsHtml flag is used to determine whether to replace characters for wrapping and such. The line looks like this:

var editValue = 
				(this.renderAsHtml ?
				this.value :
s*/g,"").replace(/<br/?>/gi, "

It appears to me that the true and false statements are in reverse order. The replacement characters occur if this.renderAsHtml == false when I believe the intent was to replace them if renderAsHtml is set to true. This causes textareas to destroy data in textareas wrapped in InlineEditBoxes?, as well as display them improperly.

Change History (5)

comment:1 Changed 13 years ago by guest

In addition at line 200, I believe the intent for the newline replacement was meant to be / /g instead of " ", which only replaces the first newline it comes across. I believe this because the replacement back to newlines is done using replace(/<br/?>/gi, " ") at line 129.

this.value = this.value.replace(/&/gm, "&amp;").replace(/</gm, "&lt;").replace(/>/gm, "&gt;").replace(/"/gm, "&quot;")


", "<br>");

comment:2 Changed 13 years ago by guest

The _setDisplayValue: function at line 212 is also affected by this issue. The parameter val will always contain <br> if you delete everything from the textarea that is within the inlineeditbox and cause the input area not to contain this.noValueIndicator, but instead appear to be blank.

_setDisplayValue: function(/*String*/ val){

summary: inserts specified HTML value into this node, or an "input needed" character if node is blank

this.displayNode.innerHTML = val


comment:3 Changed 13 years ago by bill

Description: modified (diff)
severity: criticalnormal

Hi. The comment for renderAsHtml says:

// renderAsHtml: Boolean
//		Set this to true if the specified Editor's value should be interpreted as HTML
//		rather than plain text (ie, dijit.Editor)

which is meant to mean that you set renderAsHtml to true only for widgets where setDisplayValue()/getDisplayValue() take HTML, which I think is *just* the editor at this point. It's not Textarea, which is plain text. You are using the default value of renderAsHTML = false, right?

Since InlineEditBox?.value is HTML, InlineEditBox?.edit() need to convert it to plain text before passing the value to TextBox?, which means that the replace() should happen, and it does happen since renderAsHtml is false. So the order looks correct to me.

You are right about the replace(" ") call.

It's good that you listed where you think the error in the code is, but can you also write down what actual problem you are seeing, and attach a test case if the test_InlineEditBox.html file isn't sufficient to reproduce the problem? Thanks!

comment:4 Changed 13 years ago by bill

Oh wait, I see, the save() function is incorrect. It converts from plain text to HTML if renderAsHtml=true, whereas it should convert if renderAsHtml==false. I'll fix.

comment:5 Changed 13 years ago by bill

Resolution: fixed
Status: newclosed

(In [12030]) Fix problems converting value from TextBox? to be displayed in InlineEditBox?. Fixes #5580.

Note: See TracTickets for help on using tickets.