fix: handle window property access in sandboxed environments

Wraps window.self === window.top check in try-catch to prevent
TypeError in Instagram iOS WebView where window.webkit.messageHandlers
is undefined. Defaults to false if error occurs.

Fixes FORMBRICKS-PP
This commit is contained in:
Cursor Agent
2026-02-27 21:37:48 +00:00
parent 58d5de7d45
commit ae553ab59a
@@ -169,7 +169,13 @@ export function Survey({
);
}, [survey.variables]);
const autoFocusEnabled = autoFocus ?? window.self === window.top;
const autoFocusEnabled = (() => {
try {
return autoFocus ?? window.self === window.top;
} catch {
return autoFocus ?? false;
}
})();
// Block-based navigation: track current block ID instead of question ID
const [blockId, setBlockId] = useState(() => {