diff --git a/common/changes/office-ui-fabric-react/withResponsiveModeError_2017-06-08-12-44.json b/common/changes/office-ui-fabric-react/withResponsiveModeError_2017-06-08-12-44.json new file mode 100644 index 00000000000000..d1aee3540cd18d --- /dev/null +++ b/common/changes/office-ui-fabric-react/withResponsiveModeError_2017-06-08-12-44.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "office-ui-fabric-react", + "comment": "withResponsiveMode: Adding error handling around the case where window.innerWidth throws an exception.", + "type": "patch" + } + ], + "packageName": "office-ui-fabric-react", + "email": "admitt@microsoft.com" +} \ No newline at end of file diff --git a/packages/office-ui-fabric-react/src/utilities/decorators/withResponsiveMode.tsx b/packages/office-ui-fabric-react/src/utilities/decorators/withResponsiveMode.tsx index 85c0318046908a..3680f2b278c720 100644 --- a/packages/office-ui-fabric-react/src/utilities/decorators/withResponsiveMode.tsx +++ b/packages/office-ui-fabric-react/src/utilities/decorators/withResponsiveMode.tsx @@ -75,8 +75,13 @@ export function withResponsiveMode

RESPONSIVE_MAX_CONSTRAINT[responsiveMode]) { - responsiveMode++; + try { + while (win.innerWidth > RESPONSIVE_MAX_CONSTRAINT[responsiveMode]) { + responsiveMode++; + } + } catch (e) { + // Return a best effort result in cases where we're in the browser but it throws on getting innerWidth. + responsiveMode = ResponsiveMode.large; } } else { if (_defaultMode !== undefined) {