[Xsltforms-support] [PATCH] Reworked Dialogs to fix show-hidding problems
Brought to you by:
alain-couthures
From: Kostis A. <ank...@gm...> - 2010-04-15 12:43:40
|
HI, OK, i crafted a solution that prevents the «focus-remaining-in-show-dialog-trigger» problem from re-opening the same modal-dialog multiple times on [Enter] key and then not hidding its "surround" modal-panel . The same solution also solves the (unreported) general problems of invoking multiple times <xf:show> and <xf:hide> for the same dialog-ids. PROBLEM ------------- The accounting held of opened-dialogs on Dialog.show()/hide() is not correct, resulting in the "surround"-modal-panel: a) to not close when all dialogs are hidden, or b) to close even if more modal-dialogs are left open, as demonstrated by the test-case xform for multiple modal dialogs: file 'multipleModalDialogs.xml': http://pastebin.com/VyTVA3w0 (NOTE that in IE the xf:select controls in the test-xform fail(!) on initialization, this must be another problem, since it fails even with the older revision.) SOLUTION ------------------ This idea is simple, * On Dialog.show(), depending on the target dialog, we should: a) ignore it if it is the currently showing top-dialog, b) or re-order it, if it is a previously opened but overlaped dialog. * On Dialog.hide() we should just ignore any ids refering to not opened dialogs. IMPLEMENTATION ----------------------- >From the solution description it is obvious that a simple var pointing the currently showing dialog, updated with the id whenever a new dialog opens, is not enough, since when a dialog is closed, we need to know the next top-dialog. ==> Therefore we need to maintain an *ordered* stack-of-opened-dialogs. <== This stack must be a mathimatical "set", meaning that no dialog should exist more than once within it, assuming that a dialog page-element is presented at most once (no cloning). Also, the z-index would increase on every dialog appearence, even if the dialog was open before, to cover any overllaping ones. Eventually, the z-index might increase more times than it decreases. Therefore, the hide() logic now must now hide the "surround" modal-shade-panel when the stack is empty, (instead of when the z-index becomes 0, as was done so far) and when all dialogs are hidden, it is reset to zero(0). There was indeed such a dialogs-stack in the code, the Dialog.dialogs[] var, but it was not maintained correctly, if at all. In the process, i needed a utility removeArrayItem(array, item) function. * Patch against rev385, checked mannually against Firefox, Chrom, IE. http://pastebin.com/HitEG33f NOTE that i cannot build it, i have already asked instructions about how to check rewritting-rules in a previous mail. I hope this patch gets accepted soon, since it solves a serious usability BUG on modal-dialogs. Regards Kostis PS: In my codebase i have also patched the appearence of the modal and modeless dialogs to use use correct css centering on modern browsers (not-IE6 that is...). I'm hoping to wrap it up in a separate patch and submit it in this mailling list someday. I believe then it would worth the effort to provide for <xf:message @level="modeless|ephemeral"> using this reworked Dialog stanza. On Wed, Apr 14, 2010 at 9:03 PM, Kostis Anagnostopoulos <ank...@gm...> wrote: > I think i found the problem. > > The problem in these 2 browsers stems from the fact that after the > dialog get shown due to some show-trigger activation, > that focused-trigger remains its focus. > So, when pressing [Enter], the show-trigger control gets activated once more, > and the var Dialog.depth get increased, although the dialog is already visible. > I remind that the dialog-surround is hidden when the Dialog.depth var > becomes zero. > Eventually, there are not enough dialogs to decrease Dialog.depth to > hide the dialog-surround div. > > Now i have to think of a fix...:-) > > > On Wed, Apr 14, 2010 at 8:31 PM, Kostis Anagnostopoulos > <ank...@gm...> wrote: >> Hi again, >> >> A show-stfopping bug exists on <xf:dialog> for IE and FF: >> >> If after a dialog has been opened, >> the user presses [Enter], >> then a <xf:hide>action fails to completely hide the dialog, >> since the back-shade remains >> >> Reported agaisnt FF and IE, rev385. >> Chrome OK. >> >> >> Regards, >> Kostis >> >> file: simpleDialogCloseProblem.xml >> ------------------- >> <?xml version="1.0" encoding="UTF-8"?> >> <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> >> <?xsltforms-options debug="yes" lang="en"?> >> <html >> xmlns="http://www.w3.org/1999/xhtml" >> xmlns:xf="http://www.w3.org/2002/xforms" >> xmlns:ev="http://www.w3.org/2001/xml-events" >>> >> <head> >> <title>Dialog Closing Problem Instance</title> >> >> <xf:model id="model-main" > >> <xf:instance><root/></xf:instance> >> </xf:model> >> >> </head> >> >> <body> >> <xf:trigger> >> <xf:label>Show</xf:label> >> <xf:show dialog="dlg1" ev:event="DOMActivate" /> >> </xf:trigger> >> >> <xf:dialog id="dlg1" > >> <p>In Firefox or IE, press [Enter] before hitting 'OK' and the >> dialog-shade does not close anymore!</p> >> <xf:trigger> >> <xf:label>OK</xf:label> >> <xf:hide dialog="dlg1" ev:event="DOMActivate" /> >> </xf:trigger> >> </xf:dialog> >> </body> >> </html> >> > |