In the project I am working on currently there is a lot of use of modal dialogs and they are custom themed. The theming code relies on catching the dialog:aftercreate event raised by the Drupal dialog API.
Because Automated Logout uses the jQuery dialog API directly, this event is not raised and as a result the logout modal does not go through the custom theme code, hence its display and behaviour characteristics are incorrect. (Worse, because of how the theme is set up it is actually invisible, but that's not relevant for this issue.)
The Drupal dialog API is being loaded anyway by the module's libraries.yml, so I think it makes sense to use it to get the benefit of the extra events it makes available.
Patch to follow.
| Comment | File | Size | Author |
|---|---|---|---|
| #41 | autologout-use-Drupal-dialog-3339695-41.patch | 19.61 KB | inregards2pluto |
Issue fork autologout-3339695
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
alfaguru commentedComment #3
lukusTested and this is now working well.
Comment #5
kiwimind commentedHave tested the patch and it appears to solve one of the issues that I raised on https://www.drupal.org/project/autologout/issues/3361785, so I'm happy that the code does what it's supposed to.
Prior to installing this patch, not only was it using jQuery, but it seemed to be inconsistent with the regularity of displaying the modal. Now it's showing every time.
Going to need to sort out the failing tests though.
Comment #8
deaom commentedAdded the patch to issue fork for easier maintaining. The tests are failing because of the core migration issue #3192893: [META] Serialization issues in Migration tests, but the code provided does seem to work, but setting the status to needs review, so somebody else can also again re-test and confirm it's working as expected.
Comment #10
admirlju commentedRebased the MR, tests are passing, testing by hand the modal also works fine.
While the patch is the same as the issue fork, I'll hide the file since DrupalCI tests are deprecated, and without the tests fix they will never pass, if you need a patch you can use plain diff or generate a patch file using GitLab.
Setting the issue to RTBC.
Comment #11
admirlju commentedComment #12
deaom commentedChanged as much of JQuery to plain JS as I could, also removed the duplicated dialogs appearing when clicking on "Yes" button. There could be an issue of logging out after 10s after first "Yes" in D10, which is covered in #3390135: Drupal 10 second dialog logout. Needs manual testing to confirm everything is working as expected, the automated test are passing.
Comment #13
admirlju commentedLocal and gitlabCI tests are passing, testing by hand also works correctly. Just in case locally merged #3390135: Drupal 10 second dialog logout and that fixed the second dialog instantly closing. With this fix, there is no need for #3390069: Multiple dialogs open. I think this can be merged.
Comment #14
jrglasgow commentedThe fork appears to have merge conflicts, please fix and I will merge them in.
Comment #16
david.muffley commentedFixed merge conflicts. Back to you @jrglasgow.
Comment #18
joseph.olstadFixed for 2.0.x-dev
Comment #19
joseph.olstadSetting to RTBC for 1.x
Comment #20
japerryComment #21
joseph.olstad*EDIT*
oops
*END EDIT*
Comment #22
joseph.olstadsetting back
Comment #23
dmrupp commentedI am testing this patch with version 2.0.0 and it appears that these changes:
$(event.target).trigger('preventAutologout'); => document.dispatchEvent(new Event('preventAutologout'));
$('body').bind('preventAutologout', function (event) { => document.body.addEventListener('preventAutologout', function (event) {
are not properly triggering the 'preventAutologout' event. I'm being logged out despite 'mousemove' & 'keyup' events triggering, and I'm not seeing the preventAutologout event happening at all.
Update: doing more testing, and I believe the issue can be resolved with this change, adding ".body" into the dispatchEvent() lines.
document.body.dispatchEvent(new Event('preventAutologout'));
The issue appears to be that some of the JS is using document.xyz and others using document.body.xyz.
Comment #24
joseph.olstadbased on latest report
Comment #25
dmrupp commentedI've updated the branch to fix the JS scope and event issues I found.
Comment #30
tomtech commentedHi all,
The MR resolved most of the issues I was also encountering, but the attachBehaviors was firing multiple times. This caused init() to be invoked multiple times stacked. While clicking "Yes" would dismiss the dialog, the subsequent init() calls would still invoke logout shortly thereafter.
The code tries to prevent this by checking if the context is "document", but there can still be multiple attach calls with document as the context.
I've added a commit that uses drupal once, so that the behavior is only attached once, which seems to resolve this issue.
I also add the new classes property, so this works with D10.3.
Lastly, I created a new fork that targets the 2.x branch, given that is the latest version.
Comment #31
deaom commentedThe events are getting triggered with the document.body.change. The addition of once does not completely resolve the issue of logging our after clicking yes in the dialog. It does resolve it on a first yes click, but after the third or forth time, the automatic logout still happens.
The logging out even when clicking yes, does seem to be resolved in #3390135: Drupal 10 second dialog logout, so marking this issue as RTBC, so it can get first merged so the other issue can get tested and possibly merged and then any additional corrections can be applied to it.
Comment #32
the_g_bomb commentedAdded some queries to the MR
Comment #33
the_g_bomb commentedI think this is an important ticket to get merged next. Hopefully the queries can be looked at, and this can be prioritised>
With this in some of the other tickets may be resolved already, and so the march towards #3390554: [META] Roadmap to new release can progress.
Comment #35
the_g_bomb commentedI was having issues with the dialogue opening and closing, and also with the Yes button extending the time.
I have built on #76, but altered a couple of things to address the concerns mentioned above.
Please review the new MR.
Comment #36
the_g_bomb commentedComment #37
the_g_bomb commentedComment #40
inregards2plutoJust tested MR90 and can confirm that the multiple modal issue referenced in https://www.drupal.org/project/autologout/issues/3469258 is resolved by this MR. As mentioned in comment #31, the issue of logging out when clicking "Yes" is resolved for the first couple of clicks, but auto logout happens on the 3rd or 4th click. But (again), as mentioned, the follow on changes in https://www.drupal.org/project/autologout/issues/3390135 fix the issue.
I've attached a patch for anyone else who wants to test the MR.
I agree with others here though that this is a high priority ticket to get merged in so we can move forward with incorporating fixes from other tickets for a new release.
I did push up a commit fixing the bulk of the eslint errors. I don't think it makes sense to try and resolve the outstanding phpstan errors on the MR since the associated files look like they're only relevant to d6 and d7, so it might be better served to have a separate issue ticket resolving the deprecation errors.
Comment #41
inregards2plutoReplacing my previous patch with one that is correctly exported '^^
Comment #42
deaom commentedWill mark this RTBC based on the last comment. It's hard to check changes in code, when there are multiple branches that basically do the same. The changes then get lost and it takes too much effort to actually find the changes made.
The only issue I have is with the failing tests for composer (next major). Probably the gitlab-ci file is not updated for the newer version, but that can be a separate issue if needed (did not check if already exists/is solved).
Comment #43
the_g_bomb commentedAmazing, thank you. As soon as I get a moment, I'll get this merged and the others mentioned in: #3390554: [META] Roadmap to new release
Comment #44
deaom commentedThe issue with the composer failing seems to be because of js_cookie dependency. And I think there is an issue that already removes that.
Comment #45
the_g_bomb commentedI have merged #3557620: Remove JS Cookie dependency to 2.x and then added that to this branch to tidy up the failing tests.
Comment #47
the_g_bomb commentedMerged