#9274 closed defect (fixed)
EnterKeyHandling plugin with blockMode=div does not work well
Reported by: | Douglas Hays | Owned by: | Douglas Hays |
---|---|---|---|
Priority: | high | Milestone: | 1.4 |
Component: | Editor | Version: | 1.3.0 |
Keywords: | Cc: | liucougar | |
Blocked By: | Blocking: |
Description
Tested with Safari 3 and 4 on WinXP.
<div dojoType="dijit.Editor" extraPlugins="[{name:'dijit._editor.plugins.EnterKeyHandling', blockNodeForEnter:'DIV'}]" ></div>
Focus the editor and press the Enter key 3 times. The input caret disappears and an exception is thrown in EnterKeyHandling?.js
range = selection.getRangeAt(0);
selection.rangeCount == 0 so getRangeAt(0) throws an index out of range error.
Attachments (2)
Change History (11)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Owner: | changed from liucougar to Douglas Hays |
---|---|
Summary: | EnterKeyHandling plugin does not work with Safari → EnterKeyHandling plugin with blockMode=div does not work with Safari |
Thanks for tracking that down. It's fine w/me if you add a window parameter to dijit.range.create(). In any case create() and getSelection() should have a consistent API.
BTW I get the errors on safari/mac too. Also, the errors only happen (on mac or PC) when blockMode=div is specified, not just by using the EnterKeyHandling plugin (which is lucky since EnterKeyHandling plugin is a default plugin of the editor).
comment:3 Changed 12 years ago by
Another annoying behavior when using blockMode=DIV, node.scrollIntoView(false) is being called in the EnterKeyHandling? plugin, so if you scroll the editor content down, and hten insert a blank line in the middle of the editor client area, the input caret jumps to the bottom. It should be calling dijit.scrollIntoView.
comment:4 Changed 12 years ago by
Firefox 3 throws an exception as well. Using 9274.html, focus the editor, type an "a". Then ctrl+A to select all and press BackSpace? followed by Enter. NS_ERROR_FAILURE exception thrown.
comment:5 Changed 12 years ago by
Another exception in the LI processing in EnterKeyHandling:
If Enter is pressed on an empty LI, then the list processing is terminated.
But the LI is emptied with innerHTML= but this upsets Safari who had the input caret at the old innerHTML content and so the range is deleted which again causes the getRangeAt(0) to fail. The LI will need to be emptied with selection/range processing.
comment:6 Changed 12 years ago by
Cc: | liucougar added |
---|---|
Summary: | EnterKeyHandling plugin with blockMode=div does not work with Safari → EnterKeyHandling plugin with blockMode=div does not work well |
Summary of failing scenarios being addressed:
Safari:
1) Focus the editor, press Enter twice, 2 different exceptions thrown.
2) Focus the editor, type a and press Enter repeatedly until a vertical scrollbar appears. Note you're only about 1/2 way down since extra blank lines are inserted for each Enter.
3) Save steps as 2. Then press down arrow until at the end of the content. Now up arrow until the input caret is at the top of the window (scrollabar still at the bottom). In column 1, type an a and press Enter twice. The scrollbar jumps to the top.
Firefox 3:
1) Focus the editor, type an a and ctrl+a and the BackSpace? and Enter. Exception.
IE:
1) Focus, press ctrl+\ (insertUnorderedList) twice and then Enter. alert pops up.
2) Focus, press ctrl+\. Input caret disappears.
3) Focus, type a, then press ctrl+a (select all) and then BackSpace?. Browser "back" function executes.
4) Focus, press Enter. Input caret disappears.
5) Focus, type abc and double-click the text to select it and press Enter. Exception.
6) Focus, type abc and double-click the text to select it, press ctrl+\ to create a list with the text. Press the End key and Enter twice. Press ctrl+a to select all and then Enter. Exception.
Changed 12 years ago by
Attachment: | 9274_trunk.patch added |
---|
Patch to fix listed problems. Needs review to check for regressions.
comment:7 Changed 12 years ago by
Soliciting comments on Editor patch 9274_trunk.patch before committing...
comment:8 Changed 12 years ago by
Looks good to me. I don't know enough about this plugin to really comment on it in detail.
comment:9 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [17925]) Fixes #9274 !strict. Change to dijit.scrollIntoVIew to work inside an iframe. Added optional window parameter to dijit.range.create. Preserved selection point during DOM manipulation to maintain input caret. Changed native scrollIntoView calls to dijit.scrollIntoView. Added EnterKeyHandling?/DIV plugin to existing test_Editor.html test. Fixed some style issues.
dijit.range.create() uses dojo.doc instead of this.editor.document but dijit.range.getSelection(this.editor.window) gets a window parameter, so the range document and selection window do not correspond and only Safari is noticing.
Either dijit.range.create needs an optional window or document parameter OR it needs to be surrounded by withGlobal() which is a little heavy.