Skip to content
Merged

fix bug #7715

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion apps/web-tdesign/src/adapter/component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,17 @@ async function initComponentAdapter() {
DatePicker,
// 自定义默认按钮
DefaultButton: (props, { attrs, slots }) => {
return h(Button, { ...props, attrs, theme: 'default' }, slots);
let ghost = false;
let variant = props.variant;
if (props.variant === 'ghost') {
ghost = true;
variant = 'base';
}
Comment on lines +168 to +173
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Preserve explicit ghost input instead of forcing false.

At Line 168 and Line 176, ghost defaults to false and then overrides incoming props.ghost. That breaks callers explicitly passing ghost: true when variant !== 'ghost'.

Proposed fix
-      let ghost = false;
-      let variant = props.variant;
-      if (props.variant === 'ghost') {
-        ghost = true;
-        variant = 'base';
-      }
+      const isGhostVariant = props.variant === 'ghost';
+      const ghost = isGhostVariant || Boolean(props.ghost);
+      const variant = isGhostVariant ? 'base' : props.variant;

Also applies to: 176-176

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web-tdesign/src/adapter/component/index.ts` around lines 168 - 173, The
current logic unconditionally sets ghost = false then overrides it, which
discards an explicit props.ghost passed by callers; update the initialization to
preserve props.ghost (e.g., ghost = props.ghost ?? false) and only force ghost =
true when props.variant === 'ghost' while still setting variant = 'base' in that
case; ensure no later code unconditionally resets ghost to false. Target the
ghost and variant handling around the block using props.variant and props.ghost
in this file (the variables named ghost and variant).

return h(
Button,
{ ...props, ghost, variant, attrs, theme: 'default' },
slots,
);
},
Divider,
IconPicker: withDefaultPlaceholder(IconPicker, 'select', {
Expand Down
Loading