plone / mockup

A collection of client side patterns for faster and easier web development
http://plone.github.io/mockup/
BSD 3-Clause "New" or "Revised" License
47 stars 93 forks source link

How to set default modal timeout or handle timeouts correctly? #1363

Open krissik opened 8 months ago

krissik commented 8 months ago

Sometimes we see "error happened timeout do something" messages in Browser Console after clicking "Save" on a modal. We are wondering if it is possible to increase the default value of 5000 which is set here . It is far to low for us b/c diazo is sometimes very slow.

Or maybe we need to handle it in some way, b/c there is options.onTimeout here ?

We hit the timeout while editing values in portal registry using /portal_registry view and while editing properties of pages and folders which have a mosaic layout.

petschki commented 8 months ago

The general timeout setting for pat-plone-modal is: {'actionOptions': {'timeout': 5000}} There are "global" pattern options in the config registry set via plone.patternoptions ... you can adjust the default value to:

{
    'pickadate': '{"date": {"selectYears": 200}, "time": {"interval": 5 } }',
    'plone-modal': '{"actionOptions": {"displayInModal": false, "timeout": 30000}}'
}

you see these options are set on the <body> tag, because patternslib "acquires" the options from its parent nodes ...

NOTE: These options are generated by @@plone_patterns_settings defined in Products.CMFPlone.patterns.view.PatternsSettingsView so if you need some extra logic you can override this browserview with your own ...

krissik commented 8 months ago

Many thanks. I have changed plone.patternoptions in portal_registry but still get timeout error. I have saved the setting (there was an timeout error but it was saved in background) and reloaded portal_registry. Then I checked that the new timeout is set in source code of the page (which was the case)

pat-modal-registry-sourcecode

opened the modal to change plone.patternoptions again and saved it without changing something. I still get the timeout error after 5 seconds and the modal is not closing.

pat-modal-registry

Did I miss something?

petschki commented 8 months ago

Aha. Just found out, that the portal_registry links have the class pat-modal and not pat-plone-modal. So this is the default patternslib modal and (of course) doesn't get the options from data-pat-plone-modal 🤔

Unfortunately I didn't find any timeout option here https://github.com/Patternslib/Patterns/blob/master/src/pat/modal/modal.js ... but maybe @thet can add some more insights on this?

NOTE: you can add ?loglevel=DEBUG to your browser address and open the console. There you see the patternslib debug log and can investigate the initialized elements with their pattern options. The pattern code is instantinated as pattern-<pattern_name> attribute on the DOM element.