bug: YUI RTE firing change events when any field gets focus

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

bug: YUI RTE firing change events when any field gets focus

Adrian Baker-3
When running html-area.xhtml, if you click on the input field at the top of the page, the HTML inside the RTE below is reformatted, resulting in an xforms-value-changed event.

The particular HTML which triggers this is the <em> tag - the way the RTE is being used means that YUI will alternately produce both <em> and <i> tags. However other more complex markup also seems to trigger the issue.
Reply | Threaded
Open this post in threaded view
|

Re: bug: YUI RTE firing change events when any field gets focus

Adrian Baker-3
After some more debugging, it seems that the RTE  it seems that the series of events on the
- YUI RTE fires nodeChanged on page load
- ORBEON.widgets.RTE.changeEvent gets called, this forces focus to the RTE. So when the page is loaded, Orbeon believes that the RTE has focus (this is probably problem in of itself).
- when the user focuses on *any* field, ORBEON.widgets.RTE.focusOnAnyFormControl is called, resulting in a change event for the RTE being fired.

I think if the focus-on-load issue was fixed, at least this problem might be restricted to the case when the user focuses on the RTE itself, rather than anywhere on the page.

Adrian Baker wrote
When running html-area.xhtml, if you click on the input field at the top of the page, the HTML inside the RTE below is reformatted, resulting in an xforms-value-changed event.

The particular HTML which triggers this is the <em> tag - the way the RTE is being used means that YUI will alternately produce both <em> and <i> tags. However other more complex markup also seems to trigger the issue.
Reply | Threaded
Open this post in threaded view
|

Re: bug: YUI RTE firing change events when any field gets focus

Adrian Baker-3
YUI RTE fires an afterNodeChanged as one of the last things it does during initialisation (after editorContentLoaded is fired). So a fix for this is to only register Orbeon's changeEvent function when the first afterNodeChanged event is received:

        // RTE fires afterNodeChange right at the end of initialisation, which mistakenly results
        // in changeEvent being called onload, which has a side-effect of making Orbeon think the RTE
        // has focus. Avoid this by only registering the changeEvent listener when the first afterNodeChange
        // event is received.
        var registerChangeEvent = function() {
                yuiRTE.on("editorKeyUp", function() { changeEvent(control.id); });
                yuiRTE.on("afterNodeChange", function() { changeEvent(control.id); });
                yuiRTE.removeListener("afterNodeChange", registerChangeEvent);
        };
        yuiRTE.on("afterNodeChange", registerChangeEvent);
Reply | Threaded
Open this post in threaded view
|

Re: bug: YUI RTE firing change events when any field gets focus

Alessandro Vernet
Administrator
Adrian,

Adrian Baker wrote
YUI RTE fires an afterNodeChanged as one of the last things it does during initialisation (after editorContentLoaded is fired). So a fix for this is to only register Orbeon's changeEvent function when the first afterNodeChanged event is received: [...]
Thank you for the fix. It works great. I checked this in, and it will be in the next nightly build.

http://forge.ow2.org/tracker/index.php?func=detail&aid=313941&group_id=168&atid=350207

Alex