Copilot commented on code in PR #36330:
URL: https://github.com/apache/superset/pull/36330#discussion_r2746542307


##########
superset-frontend/src/components/KebabMenuButton/index.tsx:
##########
@@ -0,0 +1,141 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { ReactNode } from 'react';
+import { css, useTheme } from '@apache-superset/core/ui';
+import { Dropdown, Button } from '@superset-ui/core/components';
+import { Icons } from '@superset-ui/core/components/Icons';
+import type { MenuItem } from '@superset-ui/core/components/Menu';
+import type { ButtonProps } from '@superset-ui/core/components/Button';
+
+export interface KebabMenuButtonProps {
+  /**
+   * Menu items to display in the dropdown
+   */
+  menuItems: MenuItem[];
+  /**
+   * Optional: Custom icon to use instead of the default three-dot icon
+   */
+  icon?: ReactNode;
+  /**
+   * Optional: Button size (default: 'xsmall')
+   */
+  buttonSize?: ButtonProps['buttonSize'];
+  /**
+   * Optional: aria-label for accessibility
+   */
+  ariaLabel?: string;
+  /**
+   * Optional: data-test attribute for testing
+   */
+  dataTest?: string;
+  /**
+   * Optional: Button id attribute
+   */
+  buttonId?: string;
+  /**
+   * Optional: Button style (default: 'link')
+   */
+  buttonStyle?: ButtonProps['buttonStyle'];
+  /**
+   * Optional: Additional CSS for the button
+   */
+  buttonCss?: ReturnType<typeof css>;
+  /**
+   * Optional: Additional styles for the dropdown overlay
+   */
+  overlayStyle?: React.CSSProperties;
+  /**
+   * Optional: Dropdown placement (defaults to Ant Design's 'bottomLeft' if 
not specified)
+   */
+  placement?:
+    | 'bottomLeft'
+    | 'bottomCenter'
+    | 'bottomRight'
+    | 'topLeft'
+    | 'topCenter'
+    | 'topRight';

Review Comment:
   KebabMenuButtonProps hard-codes the Dropdown `placement` union, which can 
easily drift from the actual AntD/@superset-ui types. Prefer reusing the 
existing type (e.g., `DropdownProps['placement']`) instead of duplicating 
string literals here.



##########
superset-frontend/src/features/dashboards/DashboardCard.tsx:
##########
@@ -191,11 +189,10 @@ function DashboardCard({
                 isStarred={favoriteStatus}
               />
             )}
-            <Dropdown menu={{ items: menuItems }} trigger={['hover', 'click']}>
-              <Button buttonSize="xsmall" buttonStyle="link">
-                <Icons.MoreOutlined iconSize="xl" />
-              </Button>
-            </Dropdown>
+            <KebabMenuButton
+              menuItems={menuItems}
+              dataTest="dashboard-card-menu"
+            />

Review Comment:
   The issue/description calls out Welcome page card menus as part of the 
inconsistency, but this change set only switches DashboardCard/ChartCard to 
KebabMenuButton. For example, `src/features/home/SavedQueries.tsx` still uses 
`trigger={['click','hover']}` and a different icon color token. If the intent 
is to fully resolve #36324, the Welcome page card(s) should be updated too or 
the PR description/title should be narrowed accordingly.



##########
superset-frontend/src/components/KebabMenuButton/index.tsx:
##########
@@ -0,0 +1,141 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { ReactNode } from 'react';
+import { css, useTheme } from '@apache-superset/core/ui';
+import { Dropdown, Button } from '@superset-ui/core/components';
+import { Icons } from '@superset-ui/core/components/Icons';
+import type { MenuItem } from '@superset-ui/core/components/Menu';
+import type { ButtonProps } from '@superset-ui/core/components/Button';
+
+export interface KebabMenuButtonProps {
+  /**
+   * Menu items to display in the dropdown
+   */
+  menuItems: MenuItem[];
+  /**
+   * Optional: Custom icon to use instead of the default three-dot icon
+   */
+  icon?: ReactNode;
+  /**
+   * Optional: Button size (default: 'xsmall')
+   */
+  buttonSize?: ButtonProps['buttonSize'];
+  /**
+   * Optional: aria-label for accessibility
+   */
+  ariaLabel?: string;
+  /**
+   * Optional: data-test attribute for testing
+   */
+  dataTest?: string;
+  /**
+   * Optional: Button id attribute
+   */
+  buttonId?: string;
+  /**
+   * Optional: Button style (default: 'link')
+   */
+  buttonStyle?: ButtonProps['buttonStyle'];
+  /**
+   * Optional: Additional CSS for the button
+   */
+  buttonCss?: ReturnType<typeof css>;
+  /**
+   * Optional: Additional styles for the dropdown overlay
+   */
+  overlayStyle?: React.CSSProperties;
+  /**
+   * Optional: Dropdown placement (defaults to Ant Design's 'bottomLeft' if 
not specified)
+   */
+  placement?:
+    | 'bottomLeft'
+    | 'bottomCenter'
+    | 'bottomRight'
+    | 'topLeft'
+    | 'topCenter'
+    | 'topRight';
+  /**
+   * Optional: IconOrientation - 'horizontal' for horizontal dots, 'vertical' 
for vertical dots
+   */
+  iconOrientation?: 'horizontal' | 'vertical';
+}
+
+/**
+ * Standardized kebab menu button component with consistent styling and 
behavior
+ * across Welcome page cards and Dashboard/Chart cards.
+ *
+ * Features:
+ * - Uses colorTextLabel for consistent icon color
+ * - Opens on click (not hover) for better UX consistency
+ * - Wraps Ant Design Dropdown with Superset conventions
+ */
+export function KebabMenuButton({
+  menuItems,
+  icon,
+  buttonSize = 'xsmall',
+  ariaLabel = 'More Options',
+  dataTest,
+  buttonId,
+  buttonStyle,
+  buttonCss,
+  overlayStyle,
+  placement,
+  iconOrientation = 'horizontal',
+}: KebabMenuButtonProps) {
+  const theme = useTheme();
+
+  const defaultIcon =
+    iconOrientation === 'vertical' ? (
+      <Icons.EllipsisOutlined
+        css={css`
+          color: ${theme.colorTextLabel};
+          transform: rotate(90deg);
+        `}
+        iconSize="xl"
+      />
+    ) : (
+      <Icons.MoreOutlined
+        css={css`
+          color: ${theme.colorTextLabel};
+        `}
+        iconSize="xl"
+      />

Review Comment:
   This component sets icon color via a CSS `color:` rule, while most Superset 
icons use the `iconColor` prop (e.g. `src/features/home/SavedQueries.tsx:365`, 
`src/dashboard/components/SliceHeaderControls/index.tsx:569`). Using 
`iconColor={theme.colorTextLabel}` here avoids relying on styling precedence 
and aligns with the icon API.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to