aurelia / dialog

A dialog plugin for Aurelia.
MIT License
106 stars 115 forks source link

null reference error on closing dialog #391

Open jded76 opened 4 years ago

jded76 commented 4 years ago

I get this error (only on Internet Explorer and only on some rare occasions):

TypeError: Unable to get property 'focus' of undefined or null reference at restoreFocus (http://localhost:9001/vendors~a3fd09b7.01e2e1f28a3ef0d6c8d3.chunk.js:866:60) at DialogRenderer.prototype.detach (http://localhost:9001/vendors.async~253ae210.01e2e1f28a3ef0d6c8d3.chunk.js:1693:13) at Anonymous function (http://localhost:9001/vendors.async~253ae210.01e2e1f28a3ef0d6c8d3.chunk.js:1778:33) at Anonymous function (http://localhost:9001/vendors~f9ca8911.01e2e1f28a3ef0d6c8d3.chunk.js:300:7)

We can avoid this by changing this line : https://github.com/aurelia/dialog/blob/0c49b7d4fb20d8cab554a0030b3a8ecb98357cde/src/dialog-settings.ts#L125 to : public restoreFocus = (lastActiveElement: HTMLElement) => { if (lastActiveElement) { lastActiveElement.focus(); } }