refine icon indicating copy to clipboard operation
refine copied to clipboard

[BUG] ShowButton ignores custom `startIcon` when `hideText=true`, causing double icon display

Open matsuba-gs opened this issue 8 months ago • 1 comments

Describe the bug

When hideText=true is passed to ShowButton, the button body always renders <VisibilityOutlined /> regardless of any custom startIcon prop provided by the user. This causes two icons to appear simultaneously — the custom icon (rendered as startIcon) and the hardcoded VisibilityOutlined (rendered as children).

Steps To Reproduce

  <ShowButton
    recordItemId={1}
    hideText
    startIcon={<InsertDriveFileIcon />}
  />

Both InsertDriveFileIcon (as startIcon) and the default icon VisibilityOutlined (as children) are displayed.

Expected behavior

Only InsertDriveFileIcon is displayed.

Packages

  • @refinedev/cli: 2.16.49
  • @refinedev/core: 4.58.0
  • @refinedev/devtools: 1.2.17
  • @refinedev/inferencer: 4.7.1
  • @refinedev/kbar: 1.3.17
  • @refinedev/mui: 5.22.0
  • @refinedev/nextjs-router: 6.2.3
  • @refinedev/react-hook-form: 4.10.2
  • @refinedev/simple-rest: 5.0.11
  • @refinedev/supabase: 5.9.8

Additional Context

Root Cause

In the current implementation, when hideText=true, the button children are hardcoded to <VisibilityOutlined fontSize="small" {...svgIconProps} /> and the children prop passed by the user is ignored:

  {hideText ? (
    <VisibilityOutlined fontSize="small" {...svgIconProps} />
  ) : (
    children ?? label
  )}

Suggested Fix

Use the startIcon prop (if provided) as the icon instead of always falling back to VisibilityOutlined:

  const resolvedIcon = startIcon ?? <VisibilityOutlined fontSize="small" {...svgIconProps} />;

  {hideText ? resolvedIcon : children ?? label}

matsuba-gs avatar Mar 11 '26 02:03 matsuba-gs

Hi! I'd like to work on this issue if it's available.

It looks like the ShowButton component always renders VisibilityOutlined when hideText=true, ignoring a custom startIcon prop. I can update the implementation so it uses startIcon when provided and falls back to VisibilityOutlined otherwise.

santhosh290605 avatar Mar 11 '26 15:03 santhosh290605