Skip to content

feat: add javascript toggle controls for device previews#1480

Closed
Dailin521 wants to merge 1 commit intoresponsively-org:mainfrom
Dailin521:codex/responsively-490-disable-javascript
Closed

feat: add javascript toggle controls for device previews#1480
Dailin521 wants to merge 1 commit intoresponsively-org:mainfrom
Dailin521:codex/responsively-490-disable-javascript

Conversation

@Dailin521
Copy link
Copy Markdown
Contributor

Summary

This adds narrow JavaScript toggle controls for Responsively previews.

Root cause

Issue #490 already identified that webpreferences must be set when a webview is created, so changing the attribute on an already-mounted preview does not actually disable JavaScript. The same issue thread also documented that screenshot capture breaks while JavaScript is disabled, which left the existing screenshot actions unsafe in that mode.

Changes

  • add shared renderer state for which preview devices currently have JavaScript disabled
  • add a per-preview JavaScript toggle in the device toolbar overflow menu and an all-previews toggle in the main overflow menu
  • re-mount preview devices when their JavaScript mode changes so the webview is recreated with webpreferences="javascript=no"
  • disable per-preview and global screenshot actions while JavaScript is disabled, with explicit tooltip copy explaining why
  • add targeted tests for the new renderer state, the global toggle, and the screenshot-disabled toolbar behavior

Verification

  • npx vitest run src/renderer/store/features/javascript/index.test.ts src/renderer/components/ToolBar/Menu/Flyout/JavaScriptControls/index.test.tsx src/renderer/components/Previewer/Device/Toolbar.test.tsx
  • npx tsc --noEmit
  • npx eslint src/renderer/store/features/javascript/index.ts src/renderer/store/features/javascript/index.test.ts src/renderer/store/index.ts src/renderer/components/Previewer/index.tsx src/renderer/components/Previewer/Device/index.tsx src/renderer/components/Previewer/Device/Toolbar.tsx src/renderer/components/Previewer/Device/Toolbar.test.tsx src/renderer/components/ToolBar/index.tsx src/renderer/components/ToolBar/Menu/Flyout/index.tsx src/renderer/components/ToolBar/Menu/Flyout/JavaScriptControls/index.tsx src/renderer/components/ToolBar/Menu/Flyout/JavaScriptControls/index.test.tsx src/renderer/components/DropDown/index.tsx (no errors; a few legacy warnings remain in touched files)
  • npm run build:renderer currently fails in this local Windows environment before bundling because the existing delete-source-maps/rimraf wildcard path is rejected
  • npx cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.renderer.dev.ts currently falls back to the existing DLL/postinstall path and fails locally because plain yarn is not available on PATH

Closes #490

@Dailin521 Dailin521 closed this Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Turn off Javascript

1 participant