Opened 9 years ago

Closed 9 years ago

#11735 closed defect (fixed)

dijit.Editor.replaceValue does not work properly in Firefox when the editor is not visible.

Reported by: philip Owned by: Jared Jurkiewicz
Priority: high Milestone: 1.6
Component: Editor Version: 1.5
Keywords: dijit.Editor replaceValue Firefox Cc:
Blocked By: Blocking:

Description

dijit.Editor.replaceValue() has the wrong behavior in FireFox? when the editor is not visible. Instead of replacing the text in the editor window, the text is prepended to the existing text. The behavior is fine when the editor is visible, or when the browser is not FireFox?.

This example will demonstrate the problem. On Firefox, click Toggle State, Set Text, Toggle State buttons. The correct behvior is that the editor will show 'New Text'. On Firefox, you will see the new text as well as the original text.

<html dir="ltr">
<head>

  <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/tundra/tundra.css"/>

  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js" djConfig="parseOnLoad: true">
  </script>
  <script type="text/javascript">
    dojo.require("dijit.Editor");
  </script>

<body class="tundra">

<script>
  // Toggle the display of the container div
  function toggle(elem) {
    var e = document.getElementById(elem);
    if (e.style.display == 'none')
      e.style.display='';
    else
      e.style.display='none';
  }

  // Set the text of the dijit.Editor. On Firefox, this does not work if the
  // editor is not visible. In this case, the text is appended rather than
  // replaces the existing text.
  function settext(elem,text) {
    var editor = dijit.byId(elem);
    editor.replaceValue(text);
  }
</script>

<button onclick="toggle('container');">Toggle State</button>
<button onclick="settext('editor1', 'New Text');">Set Text</button>

<br/>
<div id="container">
<div dojoType="dijit.Editor" id="editor1">
  <p>Initial Text</p>
</div>
</div>

</body>
</html>

Attachments (1)

11735.patch (3.6 KB) - added by Jared Jurkiewicz 9 years ago.
Patch for the issue that leverages customUndo for state, and get/setvalue

Download all attachments as: .zip

Change History (8)

comment:1 Changed 9 years ago by bill

Component: GeneralEditor
Owner: anonymous deleted

comment:2 Changed 9 years ago by Jared Jurkiewicz

The problem is Moz codepath tries to do a selectAll for some crazy reason, before inserting the content ... which does nothing useful when it is hidden ... you can't select. It probably should just behave like IE and call setValue.

comment:3 Changed 9 years ago by Jared Jurkiewicz

Milestone: tbd1.6
Owner: set to Jared Jurkiewicz

Changed 9 years ago by Jared Jurkiewicz

Attachment: 11735.patch added

Patch for the issue that leverages customUndo for state, and get/setvalue

comment:4 Changed 9 years ago by Jared Jurkiewicz

(In [22908]) Fix for issue with replaceValue not working when editor is hidden for FF. \!strict refs #11735

comment:5 Changed 9 years ago by Jared Jurkiewicz

Testing across all browsers now...

comment:6 Changed 9 years ago by Jared Jurkiewicz

(In [22909]) Fix comment typo. \!strict refs #11735

comment:7 Changed 9 years ago by Jared Jurkiewicz

Resolution: fixed
Status: newclosed

Passed in FF, IE, Safari 5, Chrome.

Note: See TracTickets for help on using tickets.