a2ui-project / a2ui-project/a2ui

React renderer reset-styles should not affect custom registered components

未关闭
#1,267 2 条评论 1 个 reaction 已指派 1 人 已被 @ditman 认领 在 GitHub 查看
component: react renderer P2 status: needs review type: bug
主要语言
TypeScript
星标
16.4k
派生
1.3k
平均合并
2 天 13 小时
30 天内合并 PR
134

描述

## Summary

In the React renderer, the default reset rule below is also affecting downstream custom registered components:

```css
:where(.a2ui-surface) :where(*) {
all: revert;
}
```

This makes it very hard to integrate an existing design system through the custom component registry, because styles from the host component library are reset together with the built-in A2UI structure.

## Current behavior
We register custom React components through the registry, for example components backed by an existing design system such as:

* Select
* Tag
* Switch
* Tabs
* Table

These components render correctly in terms of structure, but their styles are reset by the global rule above, because they are mounted inside `.a2ui-surface`.

As a result, they fall back to plain/native-looking UI or lose visual styles entirely.

## Why this is a problem

The current reset rule is broad enough to be useful for built-in A2UI components, but it also hits custom registered components, which already have their own styling system.

This creates friction for one of A2UI's main extensibility paths: mapping server-side component types to downstream/native app components.

## Expected behavior
The React renderer should allow custom registered components to keep their own styles.

Possible directions:

1. Scope the reset so it only applies to built-in/basic catalog components.
2. Exclude custom registered component subtrees from the reset.
3. Expose an option to disable or customize the default reset behavior.
4. Provide an officially supported escape hatch for downstream component libraries.

## Suggested improvement

A practical solution would be to avoid applying all: revert to the entire .a2ui-surface subtree, and instead restrict it to the built-in structural/content nodes that the renderer owns.

That would preserve the isolation benefits for built-in components while avoiding style breakage for custom components.

## Related context
I found this existing issue, which seems related in spirit because it also points to side effects from reset-styles:

* reset-styles breaks SVG rendering #1175

https://github.com/google/A2UI/issues/1175

## Environment
* @a2ui/react: 0.8.x
* React renderer
* Custom registered components from an external design system

贡献指南

打开贡献指南

调研方向

Look at the React renderer's reset-styles, likely in a file like `packages/react/src/renderer.ts` or a stylesheet. Find the CSS rule targeting `.a2ui-surface`. Understand how custom components are registered and rendered. The fix involves modifying the CSS selector to exclude registered component subtrees, perhaps by adding a class or data attribute. Test by registering a custom component and verifying its styles are not reset.

由索引模型根据 Issue 内容生成。

评估

技术栈
css, react, typescript
领域
frontend, tooling
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
冷清
描述清晰度
描述清楚
新手友好度
55/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。