Simplebar: getScrollbarWidth crash in Firefox on Windows

Created on 7 Nov 2019  路  5Comments  路  Source: Grsmto/simplebar

In firefox (47.0.2 - latest) on windows it crashes when calling function getScrollbarWidth.

I manually checked in firefox console that this code:
getComputedStyle(document.body, '::-webkit-scrollbar').display throws the exception "Component is not available".

getComputedStyle(document.body, '::-webkit-scrollbar') itself doesn't crash though.

Anyways the solution seem to wrap the content of function getScrollbarWidth with try catch and return 0 in the catch.

Btw Firefox on Mac OS works good.
Btw Firefox on windows seems to be only browser where is the problem.
Btw Update of Firefox to latest version 56.0 didn't help.

Most helpful comment

Released a fix in latest version. Hope it helps.

All 5 comments

I wanted modify the original code and use it, but i was unable to do it. (I use react + ts) so i fixed it with this temporary hack. Official solution still needed.

if (window.getComputedStyle) {
var old = window.getComputedStyle;
window.getComputedStyle = function(element: any, pseudoElt?: any) {
var ret = old(element, pseudoElt) || {};
if (pseudoElt == '::-webkit-scrollbar') {
try {
ret.display == 'none';
} catch (e) {
return {display: 'block'};
}
}
return ret;
} as any
}

Seems like the same issue as #395.
Are you on Windows XP as well? Because latest version of FF is 70 not 56.

So it seems like the throw/catch is the best solution :/ I'll release a fix soon! Thanks for your report.

Released a fix in latest version. Hope it helps.

windows 10, thanks for the fix, now it doesn't crash, cool

Was this page helpful?
0 / 5 - 0 ratings

Related issues

idiotWu picture idiotWu  路  3Comments

Aleksandr2015 picture Aleksandr2015  路  6Comments

andrey-evstigneev picture andrey-evstigneev  路  3Comments

apopelyshev picture apopelyshev  路  7Comments

RennerBink picture RennerBink  路  3Comments