quasar
quasar copied to clipboard
[BUG] 15.10 Rapid close/open of layout-drawer causes "uncaught (in promise) null"
Noticed this issue when testing a print media listener that would close the layout drawer before print.
It is also present in the existing quasar play desktop page at: http://quasar-framework.org/quasar-play/android/index.html#/showcase/layout-demo/play-with-layout
Just bring up console and rapidly click the open/close button for the layout-drawers.
You will get errors in model-toggle.js at either line# 63 or 100 where you call "reject(null)"
I think if you remove the null it will be what you intended.
Thanks!
Hi,
- The model-toggle is Promise based. That's so you can also be able to use the reference to open/close then do something after the toggle is done. But developers also need a way to handle the scenario where you toggle while another toggle is in progress. Then the initial promise must be rejected for two reasons: devs can possibly use the Promise to do something when the promise fulfils (so we must stop that, as the initial toggle process is aborted), and secondly, devs can catch if the promise is rejected in order to abort or cleanup some process that may have already started along with the toggle. However, the initial Promise is used if the developer triggers the same action that is currently under way (show or hide).
- At this point you may think "but there should be a way to avoid rejecting if the toggle was triggered by the v-model". It is a way, but it's not the right thing to do, as before the model changing there may be a reference show()/hide() call which receives the current Promise. So the Promise must be handled and not avoided.
- There's no way to hide this warning, but in any case, it's totally harmless and does not break anything. Also, doing a "reject()" instead of "reject(null)" has the same effect, with the only difference being the thrown out value (undefined vs null).