Skip to content

Migrate Change Method Signature webview off deprecated webview-ui-toolkit#4449

Open
wenytang-ms wants to merge 4 commits into
redhat-developer:mainfrom
wenytang-ms:refactor/change-signature-native-webview
Open

Migrate Change Method Signature webview off deprecated webview-ui-toolkit#4449
wenytang-ms wants to merge 4 commits into
redhat-developer:mainfrom
wenytang-ms:refactor/change-signature-native-webview

Conversation

@wenytang-ms

@wenytang-ms wenytang-ms commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #4417

This PR is the complete fix: it both resolves the editable-cell bug and migrates the dialog off the deprecated toolkit.

Background

On Change Method Signature, editing a parameter Type (or Name / Default, or an exception Type) showed nothing while typing, and on OK the typed text was appended to the original value instead of replacing it. Root cause: the cells set contentEditable directly on the deprecated @vscode/webview-ui-toolkit vscode-data-grid-cell, whose shadow root is only <slot> — typed text became a bare text node on the host, outside the slot, so it never rendered and was read back via outerText (concatenated).

What this PR does

  1. Fixes the bug — editable cells render a real <input> while editing and read its .value on commit (visible typing + correct replace semantics).
  2. Migrates the whole dialog off the archived toolkit to native HTML elements styled with --vscode-* theme variables, and removes the dependency.

Scope

This change only touches the Change Method Signature refactoring dialog. It was the only webview in the extension that depended on @vscode/webview-ui-toolkit, so it is the only one affected by this migration. Other webviews (e.g. the dashboard) never used the toolkit and are left completely untouched.

Component mapping

Toolkit Native
VSCodeButton <button> + btn/btn-primary/btn-secondary/btn-icon
VSCodeTextField <input type=text>
VSCodeDropdown / VSCodeOption <select> / <option>
VSCodeCheckbox <label> + <input type=checkbox>
VSCodeTextArea readonly <textarea>
VSCodePanels / Tab / View native tab bar + activeTab state + conditional render
VSCodeDataGrid / Row / Cell <table>/<thead>/<tbody>/<tr>/<th>/<td>

Notes

  • Preserves the existing id scheme (parameterRow-N, parameterButton-N, parameterType-N …) so hover-to-reveal-buttons and edit/confirm/cancel logic is unchanged.
  • delegate checkbox handling moved from onClick to onChange.
  • Removed the obsolete setTextAreaCursorStyle shadow-DOM hack.
  • Tightened the webview CSP: dropped style-src 'unsafe-inline' (only the toolkit needed it; CSS is now loaded via <link> and the codicon font is a data: URL covered by font-src).
  • Removed @vscode/webview-ui-toolkit from package.json + package-lock.json.

Validation

  • tsc --noEmit — passes
  • eslint on changed files — clean
  • webpack changeSignature bundle — builds successfully; built bundle contains no vscode-data-grid references
  • Manual VS Code UI walkthrough (edit/add/remove/reorder parameters & exceptions, tabs, dropdown, checkbox, preview, reset, light/dark/high-contrast themes) recommended before merge.
…edhat-developer#4417)

The parameter Type/Name/Default and exception Type cells relied on contentEditable directly on the deprecated webview-ui-toolkit �scode-data-grid-cell. The cell's shadow root only contains a <slot>, so text typed onto the host text node is never slotted/rendered: the field looks blank while editing, and on commit the typed text was read via outerText and appended to the original value instead of replacing it.

Render a real <input> as slotted content of the cell when editing, and read the value via .value. This makes typed text visible and gives correct replace-on-commit semantics. Focus/select now run in the setState callback since the input mounts after re-render, and the obsolete contentEditable DOM-reset on cancel is removed.
…lkit

Replace all @vscode/webview-ui-toolkit React components in the Change Method Signature dialog with native HTML elements styled via --vscode-* CSS variables, and drop the archived dependency entirely.

- Buttons -> <button> with btn/btn-primary/btn-secondary/btn-icon classes
- VSCodeTextField -> <input>, VSCodeDropdown/Option -> <select>/<option>
- VSCodeCheckbox -> <label> + <input type=checkbox> (delegate handling moved to onChange)
- VSCodeTextArea -> readonly <textarea>
- VSCodePanels/Tab/View -> native tab bar with new activeTab state + conditional rendering
- VSCodeDataGrid/Row/Cell -> <table>/<thead>/<tbody>/<tr>/<th>/<td>, preserving the id scheme used by the hover/edit logic
- Removed the obsolete setTextAreaCursorStyle shadow-DOM hack

Builds on the redhat-developer#4417 editable-cell fix (native <input> read via .value), which is preserved. The dialog is the only webview that used the toolkit.
@wenytang-ms

Copy link
Copy Markdown
Contributor Author

1.55 webview

image

PR webview

image
…safe-inline'

The 'unsafe-inline' style-src was only required by the webview-ui-toolkit web components, which set inline style attributes on their hosts at runtime. After migrating to native elements, CSS is bundled to a file and loaded via <link> (covered by cspSource) and the codicon font is a data: URL (covered by font-src data:), so no inline styles remain.
@wenytang-ms

Copy link
Copy Markdown
Contributor Author

1.55 issue

beforefix.mp4

new webview

afterfix.mp4
@wenytang-ms wenytang-ms marked this pull request as ready for review June 30, 2026 08:33
@wenytang-ms

Copy link
Copy Markdown
Contributor Author

@datho7561 @jjohnstn please help review this PR, thanks!

… webview

Restore accessibility that the toolkit VSCodePanels provided: tab buttons now expose aria-selected/aria-controls and each view is a role=tabpanel labelled by its tab. Also set type=button on all native buttons so they never default to submit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant