From 4b611e8bc7be6d8a32d2022d895a7753298fea1f Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Wed, 25 Nov 2026 18:24:09 -0300 Subject: [PATCH 01/12] feat(DropdownMenu): One menu component for actions and tab overflow DropdownMenu takes DropdownMenuItem children (icon, current, destructive, disabled with a reason) and is built on Popover, so it opens as a bottom sheet on phones, with larger rows there. Disabled items stay focusable and show why under the label. The action menus in stale flags, experiments, release pipelines and integrations, and the "More tabs" overflow, move onto it. The old items-based DropdownMenu is deleted. Co-Authored-By: Claude Opus 5.5 --- .../components/DropdownMenu.stories.tsx | 103 ++++++++++---- .../e2e/helpers/e2e-helpers.playwright.ts | 12 +- frontend/web/components/IntegrationList.tsx | 46 ++++-- frontend/web/components/base/DropdownMenu.tsx | 117 ---------------- .../base/DropdownMenu/DropdownMenu.scss | 132 ++++++++++++++++++ .../base/DropdownMenu/DropdownMenu.tsx | 58 ++++++++ .../base/DropdownMenu/DropdownMenuContext.ts | 7 + .../base/DropdownMenu/DropdownMenuItem.tsx | 72 ++++++++++ .../base/DropdownMenu/DropdownMenuRow.tsx | 19 +++ .../web/components/base/DropdownMenu/index.ts | 5 + frontend/web/components/base/Popover/index.ts | 6 +- .../ExperimentActionDropdown.tsx | 28 +++- .../navigation/TabMenu/TabButton.tsx | 16 +-- .../components/navigation/TabMenu/TabItem.tsx | 6 +- .../navigation/TabMenu/TabLabel.tsx | 19 +++ .../components/navigation/TabMenu/Tabs.tsx | 115 +++++++-------- .../components/StaleSection.tsx | 30 ++-- .../ReleasePipelinesList.tsx | 131 ++++++++--------- 18 files changed, 595 insertions(+), 327 deletions(-) delete mode 100644 frontend/web/components/base/DropdownMenu.tsx create mode 100644 frontend/web/components/base/DropdownMenu/DropdownMenu.scss create mode 100644 frontend/web/components/base/DropdownMenu/DropdownMenu.tsx create mode 100644 frontend/web/components/base/DropdownMenu/DropdownMenuContext.ts create mode 100644 frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx create mode 100644 frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx create mode 100644 frontend/web/components/base/DropdownMenu/index.ts create mode 100644 frontend/web/components/navigation/TabMenu/TabLabel.tsx diff --git a/frontend/documentation/components/DropdownMenu.stories.tsx b/frontend/documentation/components/DropdownMenu.stories.tsx index 1270adc60df5..94d86aaf8207 100644 --- a/frontend/documentation/components/DropdownMenu.stories.tsx +++ b/frontend/documentation/components/DropdownMenu.stories.tsx @@ -1,45 +1,96 @@ -import React from 'react' +import React, { useState } from 'react' import type { Meta, StoryObj } from 'storybook' import { screen, userEvent, within } from 'storybook/test' -import DropdownMenu from 'components/base/DropdownMenu' +import DropdownMenu, { DropdownMenuItem } from 'components/base/DropdownMenu' +import Button from 'components/base/forms/Button' -const meta: Meta = { +const meta: Meta = { + component: DropdownMenu, parameters: { - docs: { story: { height: '260px' } }, + docs: { story: { height: '320px' } }, layout: 'centered', }, title: 'Components/Data Display/DropdownMenu', } export default meta -type Story = StoryObj +type Story = StoryObj -const DEMO_ITEMS = [ - { label: 'Edit', onClick: () => {} }, - { label: 'Duplicate', onClick: () => {} }, - { label: 'Archive', onClick: () => {} }, - { label: 'Delete', onClick: () => {} }, -] +const noop = () => undefined -export const Default: Story = { - render: () => , +const ActionsMenu = () => ( + + + Copy feature name + + + Show audit logs + + + Show history + + + Remove feature + + +) + +const SECTIONS = ['Value', 'Segment overrides', 'History', 'Settings'] + +const SectionsMenu = () => { + const [current, setCurrent] = useState(2) + return ( + {SECTIONS[current]}} + > + {SECTIONS.map((section, i) => ( + setCurrent(i)} + > + {section} + + ))} + + ) } -export const Open: Story = { +const openMenu = async (canvasElement: HTMLElement, name: string) => { + const canvas = within(canvasElement) + await userEvent.click(canvas.getByRole('button', { name })) + await screen.findByRole('dialog') +} + +export const Actions: Story = { + parameters: { chromatic: { delay: 300 } }, + play: ({ canvasElement }: { canvasElement: HTMLElement }) => + openMenu(canvasElement, 'Feature actions'), + render: () => , +} + +export const CurrentItem: Story = { + parameters: { chromatic: { delay: 300 } }, + play: ({ canvasElement }: { canvasElement: HTMLElement }) => + openMenu(canvasElement, 'History'), + render: () => , +} + +// On phones the menu opens as a bottom sheet +export const MobileSheet: Story = { + globals: { viewport: { isRotated: false, value: 'mobile1' } }, parameters: { chromatic: { delay: 300 }, - docs: { - description: { - story: - 'Menu in its open state. Storybook clicks the trigger in `play`; the menu portals into `document.body`, so it is queried via `screen` rather than the local canvas.', - }, - }, - }, - play: async ({ canvasElement }: { canvasElement: HTMLElement }) => { - const canvas = within(canvasElement) - await userEvent.click(canvas.getByRole('button')) - await screen.findByText('Edit') + docs: { story: { height: '420px', inline: false } }, }, - render: () => , + play: ({ canvasElement }: { canvasElement: HTMLElement }) => + openMenu(canvasElement, 'Feature actions'), + render: () => , } diff --git a/frontend/e2e/helpers/e2e-helpers.playwright.ts b/frontend/e2e/helpers/e2e-helpers.playwright.ts index 3bf344b6eab9..bd2ca714da9b 100644 --- a/frontend/e2e/helpers/e2e-helpers.playwright.ts +++ b/frontend/e2e/helpers/e2e-helpers.playwright.ts @@ -812,12 +812,14 @@ export class E2EHelpers { // Go to feature versions async goToFeatureVersions(featureName: string) { await this.gotoFeature(featureName); - if (await this.isElementExists('change-history')) { - await this.click(byId('change-history')); - } else { - await this.click(byId('tabs-overflow-button')); - await this.click(byId('change-history')); + // History is a tab, or an item in the "More tabs" menu when the tabs overflow + const history = this.page + .getByRole('button', { exact: true, name: 'History' }) + .filter({ visible: true }); + if (!(await history.count())) { + await this.page.getByRole('button', { exact: true, name: 'More tabs' }).click(); } + await history.first().click(); } // Compare version diff --git a/frontend/web/components/IntegrationList.tsx b/frontend/web/components/IntegrationList.tsx index da603c557cc0..236d7b82f8de 100644 --- a/frontend/web/components/IntegrationList.tsx +++ b/frontend/web/components/IntegrationList.tsx @@ -14,7 +14,7 @@ import { } from 'common/types/responses' import map from 'lodash/map' import Button from './base/forms/Button' -import DropdownMenu from './base/DropdownMenu' +import DropdownMenu, { DropdownMenuItem } from './base/DropdownMenu' import Icon from './icons/Icon' import { IonIcon } from '@ionic/react' import { close as closeIcon } from 'ionicons/icons' @@ -270,7 +270,22 @@ const Integration: FC = (props) => { } return button } - return + return ( + + {actions.map((action) => ( + + {action.label} + + ))} + + ) } return ( @@ -343,19 +358,20 @@ const Integration: FC = (props) => {
e.stopPropagation()}> edit(integration), - }, - { - dataTest: 'delete-integration', - label: 'Delete', - onClick: () => remove(integration), - }, - ]} - /> + aria-label={`Actions for ${ + props.integration.title ?? 'integration' + }`} + > + edit(integration)}> + Edit + + remove(integration)} + > + Delete + +
diff --git a/frontend/web/components/base/DropdownMenu.tsx b/frontend/web/components/base/DropdownMenu.tsx deleted file mode 100644 index 8c5daed73556..000000000000 --- a/frontend/web/components/base/DropdownMenu.tsx +++ /dev/null @@ -1,117 +0,0 @@ -import React, { useLayoutEffect, useRef, useState } from 'react' -import Icon, { IconName } from 'components/icons/Icon' -import classNames from 'classnames' -import useOutsideClick from 'common/useOutsideClick' -import { createPortal } from 'react-dom' -import { calculateListPosition } from 'common/utils/calculateListPosition' - -type MenuItem = { - icon?: IconName - label: string | React.ReactNode - onClick: (e: React.MouseEvent) => void - disabled?: boolean - tooltip?: string - dataTest?: string - className?: string -} - -type DropdownMenuProps = { - items: MenuItem[] - className?: string - buttonClassName?: string - iconClassName?: string - iconWidth?: number - iconFill?: string -} - -const DropdownMenu: React.FC = ({ - buttonClassName, - className, - iconClassName, - iconFill = '#9DA4AE', - iconWidth = 18, - items, -}) => { - const [isOpen, setIsOpen] = useState(false) - const btnRef = useRef(null) - const dropDownRef = useRef(null) - useOutsideClick(dropDownRef, () => setIsOpen(false)) - - useLayoutEffect(() => { - if (!isOpen || !dropDownRef.current || !btnRef.current) return - const listPosition = calculateListPosition( - btnRef.current, - dropDownRef.current, - ) - dropDownRef.current.style.top = `${listPosition.top}px` - dropDownRef.current.style.left = `${listPosition.left}px` - }, [btnRef, isOpen, dropDownRef]) - - return ( -
- - - {isOpen && - createPortal( -
- {items.map((item, index) => ( - { - e.stopPropagation() - if (!item.disabled) { - item.onClick(e) - setIsOpen(false) - } - }} - style={{ - zIndex: 999999, - }} - > - {item.icon && ( - - )} - {item.label} -
- } - place='right' - > - {item.tooltip ?? ''} - - ))} -
, - document.body, - )} - - ) -} - -export default DropdownMenu diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss new file mode 100644 index 000000000000..95ca2ffbd01d --- /dev/null +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss @@ -0,0 +1,132 @@ +.ds-dropdown-menu { + --ds-dropdown-menu-icon: 16px; + + display: flex; + flex-direction: column; + gap: 2px; + padding: 4px; + min-width: 200px; + + &__item, + &__row { + display: flex; + align-items: center; + min-height: 44px; + border-radius: var(--radius-md); + } + + &__item { + gap: 12px; + width: 100%; + padding: 10px 12px; + color: var(--color-text-default); + text-align: left; + + // Touch screens keep :hover after a tap, so only devices that can hover + // get it + @media (hover: hover) { + &:hover { + background: var(--color-surface-hover); + } + } + + // Inset, so the ring stays inside the row and keeps its corners + &:focus-visible { + background: var(--color-surface-hover); + border-radius: var(--radius-md); + outline-offset: -2px; + } + + &[aria-current='true'] { + font-weight: var(--font-weight-semibold); + color: var(--color-text-action); + background: var(--color-surface-action-subtle); + + .ds-dropdown-menu__icon { + color: var(--color-icon-action); + } + } + + &--destructive { + color: var(--color-text-danger); + + .ds-dropdown-menu__icon { + color: var(--color-icon-danger); + } + } + + &[aria-disabled='true'] { + color: var(--color-text-disabled); + cursor: not-allowed; + + .ds-dropdown-menu__icon { + color: var(--color-icon-disabled); + } + + &:hover, + &:focus-visible { + background: none; + } + } + } + + // The content brings its own padding, hover and active styles + &__row { + > * { + flex: 1; + } + + // A row whose content renders nothing, such as a permission check + &:empty { + display: none; + } + } + + &__label { + display: flex; + flex: 1; + flex-wrap: wrap; + align-items: center; + gap: 0 8px; + min-width: 0; + } + + // Why a disabled item can't be used; its description for screen readers + &__reason { + flex-basis: 100%; + font-size: var(--font-size-body-xs); + color: var(--color-text-secondary); + } + + // Icons draw with currentColor + &__icon { + display: flex; + flex-shrink: 0; + color: var(--color-icon-secondary); + + svg { + width: var(--ds-dropdown-menu-icon); + height: var(--ds-dropdown-menu-icon); + } + } + + // In a bottom sheet rows are larger, like native action sheets. There is no + // 16px body token, so the size is set here + &--sheet { + --ds-dropdown-menu-icon: 20px; + + .ds-dropdown-menu__item, + .ds-dropdown-menu__row { + min-height: 48px; + } + + .ds-dropdown-menu__item { + padding: 12px; + font-size: 16px; + } + + .ds-dropdown-menu__reason { + font-size: var(--font-size-body-sm); + } + } +} diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx new file mode 100644 index 000000000000..ed3e0bdc6a6b --- /dev/null +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx @@ -0,0 +1,58 @@ +import { cloneElement, FC, ReactElement, ReactNode } from 'react' +import Popover, { PopoverPlacement } from 'components/base/Popover' +import IconButton from 'components/base/IconButton' +import Icon from 'components/icons/Icon' +import classNames from 'classnames' +import { useBreakpoint } from 'common/hooks/useBreakpoint' +import { DropdownMenuCloseProvider } from './DropdownMenuContext' +import './DropdownMenu.scss' + +export type DropdownMenuProps = { + // Names the menu, and the default trigger + 'aria-label': string + // Any element; it receives the ref and open/close props. Defaults to a + // "more" button. + trigger?: ReactElement + children: ReactNode + placement?: PopoverPlacement +} + +const DropdownMenu: FC = ({ + 'aria-label': ariaLabel, + children, + placement = 'bottom-end', + trigger, +}) => { + // Popover opens as a sheet on the same breakpoint, where rows get larger + const asSheet = useBreakpoint('isPhone') + return ( + + cloneElement( + trigger ?? ( + + + + ), + props, + ) + } + > + {(close) => ( + +
+ {children} +
+
+ )} +
+ ) +} + +export default DropdownMenu diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuContext.ts b/frontend/web/components/base/DropdownMenu/DropdownMenuContext.ts new file mode 100644 index 000000000000..b21d4abf9f3e --- /dev/null +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuContext.ts @@ -0,0 +1,7 @@ +import { createContext, useContext } from 'react' + +// Lets an item close its menu even when its handler stops the click +const DropdownMenuContext = createContext<() => void>(() => undefined) + +export const DropdownMenuCloseProvider = DropdownMenuContext.Provider +export const useCloseDropdownMenu = () => useContext(DropdownMenuContext) diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx new file mode 100644 index 000000000000..597021c4582d --- /dev/null +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx @@ -0,0 +1,72 @@ +import { FC, MouseEvent, ReactNode, useId } from 'react' +import classNames from 'classnames' +import BareButton from 'components/base/forms/BareButton' +import Icon, { IconName } from 'components/icons/Icon' +import { useCloseDropdownMenu } from './DropdownMenuContext' + +export type DropdownMenuItemProps = { + children: ReactNode + onSelect: (e: MouseEvent) => void + icon?: IconName + // The selected option, as in a section switcher: ticked and announced + current?: boolean + destructive?: boolean + disabled?: boolean + // Shown on hover while disabled + disabledReason?: string +} + +const DropdownMenuItem: FC = ({ + children, + current = false, + destructive = false, + disabled = false, + disabledReason, + icon, + onSelect, +}) => { + const close = useCloseDropdownMenu() + const id = useId() + const reasonId = `${id}-reason` + const reason = disabled ? disabledReason : undefined + // aria-disabled keeps the item focusable, and the reason shows under the + // label, so keyboard and touch users both get it. Named by the label alone, + // so the reason is read once, as the description + return ( + { + if (disabled) return + onSelect(e) + close() + }} + > + {icon && ( + + + + )} + + {children} + {reason && ( + + {reason} + + )} + + {current && ( + + + + )} + + ) +} + +export default DropdownMenuItem diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx new file mode 100644 index 000000000000..a973365af07b --- /dev/null +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx @@ -0,0 +1,19 @@ +import { FC, ReactNode } from 'react' +import { useCloseDropdownMenu } from './DropdownMenuContext' + +type DropdownMenuRowProps = { + // Content that is its own control, such as a nav link + children: ReactNode +} + +// The click comes from the link inside, which handles the keyboard itself +const DropdownMenuRow: FC = ({ children }) => { + const close = useCloseDropdownMenu() + return ( +
+ {children} +
+ ) +} + +export default DropdownMenuRow diff --git a/frontend/web/components/base/DropdownMenu/index.ts b/frontend/web/components/base/DropdownMenu/index.ts new file mode 100644 index 000000000000..8383a60037cb --- /dev/null +++ b/frontend/web/components/base/DropdownMenu/index.ts @@ -0,0 +1,5 @@ +export { default } from './DropdownMenu' +export { default as DropdownMenuItem } from './DropdownMenuItem' +export { default as DropdownMenuRow } from './DropdownMenuRow' +export type { DropdownMenuProps } from './DropdownMenu' +export type { DropdownMenuItemProps } from './DropdownMenuItem' diff --git a/frontend/web/components/base/Popover/index.ts b/frontend/web/components/base/Popover/index.ts index 47263e10f2a0..5bf8b0be8525 100644 --- a/frontend/web/components/base/Popover/index.ts +++ b/frontend/web/components/base/Popover/index.ts @@ -1,2 +1,6 @@ export { default } from './Popover' -export type { PopoverProps, PopoverTriggerProps } from './Popover' +export type { + PopoverPlacement, + PopoverProps, + PopoverTriggerProps, +} from './Popover' diff --git a/frontend/web/components/experiments/ExperimentActionDropdown/ExperimentActionDropdown.tsx b/frontend/web/components/experiments/ExperimentActionDropdown/ExperimentActionDropdown.tsx index c112816c17b7..085178e3cbd8 100644 --- a/frontend/web/components/experiments/ExperimentActionDropdown/ExperimentActionDropdown.tsx +++ b/frontend/web/components/experiments/ExperimentActionDropdown/ExperimentActionDropdown.tsx @@ -6,9 +6,15 @@ import { useStartExperimentMutation, } from 'common/services/useExperiment' import { ENABLE_EXPERIMENT_LIFECYCLE } from 'components/experiments/constants' -import DropdownMenu from 'components/base/DropdownMenu' +import DropdownMenu, { DropdownMenuItem } from 'components/base/DropdownMenu' import CompleteExperimentModal from 'components/experiments/CompleteExperimentModal' +type ExperimentAction = { + label: string + onClick: () => void + destructive?: boolean +} + type ExperimentActionDropdownProps = { experimentId: number experimentName: string @@ -83,13 +89,13 @@ const ExperimentActionDropdown: FC = ({ }) }, [deleteExperiment, experimentName, params]) - const items = useMemo(() => { + const items = useMemo((): ExperimentAction[] => { switch (status) { case 'created': return [ { label: 'Start Experiment', onClick: handleStart }, { - className: 'text-danger', + destructive: true, label: 'Delete', onClick: handleDelete, }, @@ -109,7 +115,7 @@ const ExperimentActionDropdown: FC = ({ case 'completed': return [ { - className: 'text-danger', + destructive: true, label: 'Delete', onClick: handleDelete, }, @@ -119,7 +125,19 @@ const ExperimentActionDropdown: FC = ({ } }, [status, handleStart, handlePause, handleComplete, handleDelete]) - return + return ( + + {items.map((item) => ( + + {item.label} + + ))} + + ) } export default ExperimentActionDropdown diff --git a/frontend/web/components/navigation/TabMenu/TabButton.tsx b/frontend/web/components/navigation/TabMenu/TabButton.tsx index cc66c53092c7..b8bd5135f3dd 100644 --- a/frontend/web/components/navigation/TabMenu/TabButton.tsx +++ b/frontend/web/components/navigation/TabMenu/TabButton.tsx @@ -2,8 +2,8 @@ import React from 'react' import { themeClassNames } from 'components/base/forms/Button' import Button from 'components/base/forms/Button' -import ColorSwatch from 'components/ColorSwatch' -import { colorIconWarning } from 'common/theme/tokens' +import { TabItemProps } from './TabItem' +import TabLabel from './TabLabel' interface TabButtonProps { noFocus?: boolean @@ -11,7 +11,7 @@ interface TabButtonProps { onClick?: (e: React.MouseEvent) => void buttonTheme?: string className?: string - child: React.ReactElement + child: React.ReactElement children: React.ReactNode } @@ -30,12 +30,10 @@ const TabButton = React.forwardRef( } ${className}`} > - {child.props.tabLabel} - {child.props.isDirty && ( - - - - )} + ) diff --git a/frontend/web/components/navigation/TabMenu/TabItem.tsx b/frontend/web/components/navigation/TabMenu/TabItem.tsx index 622184d05abc..1c014a256db5 100644 --- a/frontend/web/components/navigation/TabMenu/TabItem.tsx +++ b/frontend/web/components/navigation/TabMenu/TabItem.tsx @@ -1,6 +1,6 @@ import { FC, ReactNode } from 'react' -type TabItemType = { +export type TabItemProps = { tabLabelString?: string tabLabel: ReactNode children: ReactNode @@ -9,9 +9,11 @@ type TabItemType = { // so positioning lives in one place and TabButton can wrap label + badge in // a flex container that prevents the badge from breaking onto a new line. isDirty?: boolean + 'data-test'?: string + id?: string } -const TabItem: FC = ({ children }) => { +const TabItem: FC = ({ children }) => { return children || (null as any) } diff --git a/frontend/web/components/navigation/TabMenu/TabLabel.tsx b/frontend/web/components/navigation/TabMenu/TabLabel.tsx new file mode 100644 index 000000000000..630bf014f9b8 --- /dev/null +++ b/frontend/web/components/navigation/TabMenu/TabLabel.tsx @@ -0,0 +1,19 @@ +import { FC } from 'react' +import ColorSwatch from 'components/ColorSwatch' +import { colorIconWarning } from 'common/theme/tokens' +import { TabItemProps } from './TabItem' + +type TabLabelProps = Pick + +const TabLabel: FC = ({ isDirty, tabLabel }) => ( + <> + {tabLabel} + {isDirty && ( + + + + )} + +) + +export default TabLabel diff --git a/frontend/web/components/navigation/TabMenu/Tabs.tsx b/frontend/web/components/navigation/TabMenu/Tabs.tsx index 455ec789273e..d3f509829ade 100644 --- a/frontend/web/components/navigation/TabMenu/Tabs.tsx +++ b/frontend/web/components/navigation/TabMenu/Tabs.tsx @@ -1,13 +1,28 @@ -import React, { ReactNode, useCallback, useMemo, useRef, useState } from 'react' +import React, { + isValidElement, + ReactElement, + ReactNode, + useCallback, + useMemo, + useRef, + useState, +} from 'react' import ModalHR from 'components/modals/ModalHR' import Utils from 'common/utils/utils' import { useHistory } from 'react-router-dom' import TabButton from './TabButton' +import { TabItemProps } from './TabItem' +import TabLabel from './TabLabel' import classNames from 'classnames' -import DropdownMenu from 'components/base/DropdownMenu' +import DropdownMenu, { DropdownMenuItem } from 'components/base/DropdownMenu' +import IconButton from 'components/base/IconButton' +import Icon from 'components/icons/Icon' import { useOverflowVisibleCount } from 'common/hooks/useOverflowVisibleCount' +// Room for the "More tabs" button, with some spare +const OVERFLOW_BUTTON_WIDTH = 48 + interface TabsProps { children: ReactNode | ReactNode[] onChange?: (index: number) => void @@ -25,9 +40,6 @@ interface TabsProps { cta?: ReactNode } -// 40px rendered button (btn padding beats its 32px width) + ms-2 margin -const OVERFLOW_BUTTON_WIDTH = 48 - const Tabs: React.FC = ({ buttonTheme, children, @@ -44,7 +56,7 @@ const Tabs: React.FC = ({ value: propValue = 0, }) => { const tabChildren = (Array.isArray(children) ? children : [children]).filter( - Boolean, + (child): child is ReactElement => isValidElement(child), ) const [internalValue, setInternalValue] = useState(0) const routerHistory = useHistory() || history @@ -68,6 +80,7 @@ const Tabs: React.FC = ({ const outerContainerRef = useRef(null) const itemsContainerRef = useRef(null) + const { isMeasuring, visibleCount } = useOverflowVisibleCount({ extraWidth: OVERFLOW_BUTTON_WIDTH, force: false, @@ -86,6 +99,9 @@ const Tabs: React.FC = ({ [tabChildren, visibleCount, disableOverflow], ) const canGrow = !isMeasuring && visibleCount === tabChildren.length + const hasOverflow = overflow.length > 0 && !isMeasuring + const tabLabelOf = (child: ReactElement) => + String(child.props.tabLabelString || child.props.tabLabel) const handleChange = useCallback( (e: React.MouseEvent, tabLabel: string, i: number) => { @@ -119,7 +135,7 @@ const Tabs: React.FC = ({ >
@@ -132,11 +148,7 @@ const Tabs: React.FC = ({ className={canGrow ? 'tab-nav-full' : ''} noFocus={noFocus} onClick={(e: React.MouseEvent) => - handleChange( - e, - String(child.props.tabLabelString || child.props.tabLabel), - i, - ) + handleChange(e, tabLabelOf(child), i) } child={child} buttonTheme={buttonTheme} @@ -146,57 +158,36 @@ const Tabs: React.FC = ({ ) })}
- {overflow.length > 0 && !isMeasuring && ( -
+ + + } > - { - const actualIndex = i + visibleCount - const active = value === actualIndex - return { - className: classNames('', [ - active - ? 'text-action fw-semibold bg-primary-opacity-5 fill-primary' - : 'hover-color-primary', - ]), - label: ( -
- - {child.props.tabLabel} - -
- ) as React.ReactNode, - onClick: (e: any) => { - handleChange( - e, - String( - child.props.tabLabelString || child.props.tabLabel, - ), - actualIndex, - ) - }, - } - })} - /> -
+ {overflow.map((child) => { + const i = tabChildren.indexOf(child) + return ( + handleChange(e, tabLabelOf(child), i)} + > + + + ) + })} +
)} {cta &&
{cta}
} diff --git a/frontend/web/components/pages/feature-lifecycle/components/StaleSection.tsx b/frontend/web/components/pages/feature-lifecycle/components/StaleSection.tsx index 2f345d07efe6..c06302a0caae 100644 --- a/frontend/web/components/pages/feature-lifecycle/components/StaleSection.tsx +++ b/frontend/web/components/pages/feature-lifecycle/components/StaleSection.tsx @@ -1,5 +1,5 @@ import React, { FC, useCallback } from 'react' -import DropdownMenu from 'components/base/DropdownMenu' +import DropdownMenu, { DropdownMenuItem } from 'components/base/DropdownMenu' import SectionShell from './SectionShell' import { useClientPagination } from 'components/pages/feature-lifecycle/hooks/useClientPagination' import { useCreateCleanupIssueMutation } from 'common/services/useGithubIntegration' @@ -132,20 +132,20 @@ const StaleSection: FC = ({ prevPage={prevPage} goToPage={goToPage} renderActions={(flag) => ( - handleCreateCleanupIssue(flag), - }, - { - icon: 'copy', - label: 'Copy Cleanup AI Prompt', - onClick: () => handleCopyCleanupPrompt(flag), - }, - ]} - /> + + handleCreateCleanupIssue(flag)} + > + Create Cleanup Issue + + handleCopyCleanupPrompt(flag)} + > + Copy Cleanup AI Prompt + + )} /> ) diff --git a/frontend/web/components/release-pipelines/ReleasePipelinesList.tsx b/frontend/web/components/release-pipelines/ReleasePipelinesList.tsx index 9e49bfc9a6a9..91ae82a2e043 100644 --- a/frontend/web/components/release-pipelines/ReleasePipelinesList.tsx +++ b/frontend/web/components/release-pipelines/ReleasePipelinesList.tsx @@ -2,8 +2,8 @@ import { useDeleteReleasePipelineMutation } from 'common/services/useReleasePipe import { PagedResponse, ReleasePipeline } from 'common/types/responses' import { useHistory } from 'react-router-dom' import Button from 'components/base/forms/Button' -import Icon, { IconName } from 'components/icons/Icon' -import DropdownMenu from 'components/base/DropdownMenu' +import Icon from 'components/icons/Icon' +import DropdownMenu, { DropdownMenuItem } from 'components/base/DropdownMenu' import PanelSearch from 'components/PanelSearch' import Tag from 'components/tags/Tag' import { useEffect } from 'react' @@ -146,13 +146,6 @@ const ReleasePipelinesList = ({ const canUnpublish = isPublished && !features?.length const canDelete = !features?.length - const getTooltip = (action: string) => { - if (isPublished) { - return `Cannot ${action} a published release pipeline` - } - return undefined - } - return ( {features?.length ?? 0}
Features
- { - history.push( - `/project/${projectId}/release-pipelines/${id}/edit`, - ) - }, - tooltip: getTooltip('edit'), - }, - { - disabled: isPublished && !canUnpublish, - icon: isPublished - ? 'minus-circle' - : ('checkmark-circle' as IconName), - label: isPublished ? 'Unpublish' : 'Publish', - onClick: () => - openChangeReleasePipelineStatusModal( - projectId, - id, - isPublished, - ), - tooltip: - isPublished && !canUnpublish - ? 'Cannot unpublish a release pipeline with in-flight features' - : undefined, - }, - { - icon: 'copy' as IconName, - label: 'Clone', - onClick: () => - openModal2( - 'Clone Release Pipeline', - , - ), - }, - { - disabled: !canDelete, - icon: 'trash-2', - label: 'Remove', - onClick: () => { - openModal2( - 'Remove Release Pipeline', - , - ) - }, - tooltip: canDelete - ? undefined - : 'Cannot remove a release pipeline with in-flight features', - }, - ]} - /> + + + history.push( + `/project/${projectId}/release-pipelines/${id}/edit`, + ) + } + > + Edit + + + openChangeReleasePipelineStatusModal( + projectId, + id, + isPublished, + ) + } + > + {isPublished ? 'Unpublish' : 'Publish'} + + + openModal2( + 'Clone Release Pipeline', + , + ) + } + > + Clone + + + openModal2( + 'Remove Release Pipeline', + , + ) + } + > + Remove + +
) From 5cde334a1bcc88b427ab7c4d41b5fc492a57ee5f Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Wed, 25 Nov 2026 18:24:11 -0300 Subject: [PATCH 02/12] refactor(OverflowNav): Use DropdownMenu for the nav overflow The project, organisation and environment navs open their overflow as a DropdownMenu instead of an InlineModal, so it is a sheet on phones. Each nav names its button with a required label, and E2E finds it by name. Co-Authored-By: Claude Opus 5.5 --- .../components/OverflowNav.stories.tsx | 3 + .../e2e/helpers/e2e-helpers.playwright.ts | 2 +- .../navigation/EnvironmentAside.tsx | 1 + .../web/components/navigation/OverflowNav.tsx | 68 ++++++++----------- .../navigation/navbars/OrganisationNavbar.tsx | 1 + .../navigation/navbars/ProjectNavbar.tsx | 1 + 6 files changed, 35 insertions(+), 41 deletions(-) diff --git a/frontend/documentation/components/OverflowNav.stories.tsx b/frontend/documentation/components/OverflowNav.stories.tsx index 75233f6a09b1..fd30cca1d60b 100644 --- a/frontend/documentation/components/OverflowNav.stories.tsx +++ b/frontend/documentation/components/OverflowNav.stories.tsx @@ -48,6 +48,7 @@ const NAV_ITEMS = ( export const ProjectNavbar: Story = { render: () => ( ( ( = ({ environmentId, projectId }) => { {E2E && createEnvironmentButton} = ({ children: _children, className = '', @@ -23,6 +27,7 @@ const OverflowNav: FC = ({ force, gap = 2, icon = ellipsisHorizontal, + label, }) => { const items = React.Children.toArray( (_children as React.ReactElement)?.props?.children || _children, @@ -30,23 +35,14 @@ const OverflowNav: FC = ({ const outerContainerRef = useRef(null) const itemsContainerRef = useRef(null) - const [open, setOpen] = useState(false) - const history = useHistory() const { isMeasuring, visibleCount } = useOverflowVisibleCount({ - extraWidth: buttonWidth + 20, + extraWidth: OVERFLOW_BUTTON_WIDTH, force, itemCount: items.length, itemsContainerRef, outerContainerRef, }) - useEffect(() => { - const unlisten = history.listen(() => { - setOpen(false) - }) - return () => unlisten() - }, [history]) - const visible = items.slice(0, visibleCount) const overflow = items.slice(visibleCount) @@ -83,31 +79,23 @@ const OverflowNav: FC = ({ {overflow.length > 0 && !isMeasuring && ( -
- - setOpen(false)} - > -
- {overflow.map((child, idx) => ( - {child} - ))} -
-
-
+ + + + } + > + {overflow.map((child, idx) => ( + {child} + ))} + )} ) diff --git a/frontend/web/components/navigation/navbars/OrganisationNavbar.tsx b/frontend/web/components/navigation/navbars/OrganisationNavbar.tsx index 15a076e8f6c1..21f11ec0e3c5 100644 --- a/frontend/web/components/navigation/navbars/OrganisationNavbar.tsx +++ b/frontend/web/components/navigation/navbars/OrganisationNavbar.tsx @@ -14,6 +14,7 @@ type OrganisationNavType = {} const OrganisationNavbar: FC = ({}) => { return ( = ({ environmentId, projectId }) => { ) return ( Date: Wed, 25 Nov 2026 18:37:01 -0300 Subject: [PATCH 03/12] fix(Integrations): Give each configured integration's menu its own name Two Grafana integrations both read "Actions for Grafana"; numbered when there are several. Co-Authored-By: Claude Opus 5.5 --- frontend/web/components/IntegrationList.tsx | 11 +++++++---- .../__tests__/configuredActionsLabel.test.ts | 16 ++++++++++++++++ .../integrations/configuredActionsLabel.ts | 9 +++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 frontend/web/components/integrations/__tests__/configuredActionsLabel.test.ts create mode 100644 frontend/web/components/integrations/configuredActionsLabel.ts diff --git a/frontend/web/components/IntegrationList.tsx b/frontend/web/components/IntegrationList.tsx index 236d7b82f8de..17a5ebc8c9ef 100644 --- a/frontend/web/components/IntegrationList.tsx +++ b/frontend/web/components/IntegrationList.tsx @@ -15,6 +15,7 @@ import { import map from 'lodash/map' import Button from './base/forms/Button' import DropdownMenu, { DropdownMenuItem } from './base/DropdownMenu' +import { configuredActionsLabel } from './integrations/configuredActionsLabel' import Icon from './icons/Icon' import { IonIcon } from '@ionic/react' import { close as closeIcon } from 'ionicons/icons' @@ -340,7 +341,7 @@ const Integration: FC = (props) => { )} {activeIntegrations && - activeIntegrations.map((integration) => ( + activeIntegrations.map((integration, index) => (
= (props) => {
e.stopPropagation()}> edit(integration)}> Edit diff --git a/frontend/web/components/integrations/__tests__/configuredActionsLabel.test.ts b/frontend/web/components/integrations/__tests__/configuredActionsLabel.test.ts new file mode 100644 index 000000000000..f4807485ab87 --- /dev/null +++ b/frontend/web/components/integrations/__tests__/configuredActionsLabel.test.ts @@ -0,0 +1,16 @@ +import { configuredActionsLabel } from 'components/integrations/configuredActionsLabel' + +describe('configuredActionsLabel', () => { + it.each` + title | index | count | expected + ${'Grafana'} | ${0} | ${1} | ${'Actions for Grafana'} + ${'Grafana'} | ${1} | ${3} | ${'Actions for Grafana, 2 of 3'} + ${undefined} | ${0} | ${1} | ${'Actions for integration'} + ${undefined} | ${0} | ${2} | ${'Actions for integration, 1 of 2'} + `( + '$title, $index of $count: $expected', + ({ count, expected, index, title }) => { + expect(configuredActionsLabel(title, index, count)).toBe(expected) + }, + ) +}) diff --git a/frontend/web/components/integrations/configuredActionsLabel.ts b/frontend/web/components/integrations/configuredActionsLabel.ts new file mode 100644 index 000000000000..638ca478ea0b --- /dev/null +++ b/frontend/web/components/integrations/configuredActionsLabel.ts @@ -0,0 +1,9 @@ +// Several configured instances of one integration need their own names +export const configuredActionsLabel = ( + title: string | undefined, + index: number, + count: number, +): string => { + const name = `Actions for ${title ?? 'integration'}` + return count > 1 ? `${name}, ${index + 1} of ${count}` : name +} From 654ed470afbaf9c6bdb3148b42588e4f4e4c1176 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Wed, 25 Nov 2026 22:43:23 -0300 Subject: [PATCH 04/12] refactor(DropdownMenu): Take an item's icon as a child Copy: the item spaces and sizes it, so any icon works, and the reason lines up with the text. Co-Authored-By: Claude Opus 5.5 --- .../components/DropdownMenu.stories.tsx | 12 ++++--- .../base/DropdownMenu/DropdownMenu.scss | 35 ++++++++++++++----- .../base/DropdownMenu/DropdownMenuItem.tsx | 16 ++++----- .../components/StaleSection.tsx | 13 +++---- .../ReleasePipelinesList.tsx | 10 +++--- 5 files changed, 52 insertions(+), 34 deletions(-) diff --git a/frontend/documentation/components/DropdownMenu.stories.tsx b/frontend/documentation/components/DropdownMenu.stories.tsx index 94d86aaf8207..4225ff760bc9 100644 --- a/frontend/documentation/components/DropdownMenu.stories.tsx +++ b/frontend/documentation/components/DropdownMenu.stories.tsx @@ -4,6 +4,7 @@ import { screen, userEvent, within } from 'storybook/test' import DropdownMenu, { DropdownMenuItem } from 'components/base/DropdownMenu' import Button from 'components/base/forms/Button' +import Icon from 'components/icons/Icon' const meta: Meta = { component: DropdownMenu, @@ -21,21 +22,24 @@ const noop = () => undefined const ActionsMenu = () => ( - + + Copy feature name - + + Show audit logs + Show history - + + Remove feature diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss index 95ca2ffbd01d..e44ff68aa803 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss @@ -42,7 +42,8 @@ color: var(--color-text-action); background: var(--color-surface-action-subtle); - .ds-dropdown-menu__icon { + .ds-dropdown-menu__icon, + .ds-dropdown-menu__label > svg { color: var(--color-icon-action); } } @@ -50,7 +51,8 @@ &--destructive { color: var(--color-text-danger); - .ds-dropdown-menu__icon { + .ds-dropdown-menu__icon, + .ds-dropdown-menu__label > svg { color: var(--color-icon-danger); } } @@ -59,7 +61,8 @@ color: var(--color-text-disabled); cursor: not-allowed; - .ds-dropdown-menu__icon { + .ds-dropdown-menu__icon, + .ds-dropdown-menu__label > svg { color: var(--color-icon-disabled); } @@ -82,22 +85,38 @@ } } - &__label { + &__content { display: flex; flex: 1; - flex-wrap: wrap; - align-items: center; - gap: 0 8px; + flex-direction: column; min-width: 0; } + // The label and an optional icon before it + &__label { + display: flex; + align-items: center; + gap: 12px; + + > svg { + flex-shrink: 0; + width: var(--ds-dropdown-menu-icon); + height: var(--ds-dropdown-menu-icon); + color: var(--color-icon-secondary); + } + } + // Why a disabled item can't be used; its description for screen readers &__reason { - flex-basis: 100%; font-size: var(--font-size-body-xs); color: var(--color-text-secondary); } + // Lines up with the text, not the icon + &__label:has(> svg) + &__reason { + padding-left: calc(var(--ds-dropdown-menu-icon) + 12px); + } + // Icons draw with currentColor &__icon { display: flex; diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx index 597021c4582d..8c1f81fb47c6 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx @@ -1,18 +1,18 @@ import { FC, MouseEvent, ReactNode, useId } from 'react' import classNames from 'classnames' import BareButton from 'components/base/forms/BareButton' -import Icon, { IconName } from 'components/icons/Icon' +import Icon from 'components/icons/Icon' import { useCloseDropdownMenu } from './DropdownMenuContext' export type DropdownMenuItemProps = { + // The label, with an optional icon first: Copy children: ReactNode onSelect: (e: MouseEvent) => void - icon?: IconName // The selected option, as in a section switcher: ticked and announced current?: boolean destructive?: boolean disabled?: boolean - // Shown on hover while disabled + // Shown under the label while disabled disabledReason?: string } @@ -22,7 +22,6 @@ const DropdownMenuItem: FC = ({ destructive = false, disabled = false, disabledReason, - icon, onSelect, }) => { const close = useCloseDropdownMenu() @@ -47,13 +46,10 @@ const DropdownMenuItem: FC = ({ close() }} > - {icon && ( - - + + + {children} - )} - - {children} {reason && ( {reason} diff --git a/frontend/web/components/pages/feature-lifecycle/components/StaleSection.tsx b/frontend/web/components/pages/feature-lifecycle/components/StaleSection.tsx index c06302a0caae..6731fcdd7b29 100644 --- a/frontend/web/components/pages/feature-lifecycle/components/StaleSection.tsx +++ b/frontend/web/components/pages/feature-lifecycle/components/StaleSection.tsx @@ -1,5 +1,6 @@ import React, { FC, useCallback } from 'react' import DropdownMenu, { DropdownMenuItem } from 'components/base/DropdownMenu' +import Icon from 'components/icons/Icon' import SectionShell from './SectionShell' import { useClientPagination } from 'components/pages/feature-lifecycle/hooks/useClientPagination' import { useCreateCleanupIssueMutation } from 'common/services/useGithubIntegration' @@ -133,16 +134,12 @@ const StaleSection: FC = ({ goToPage={goToPage} renderActions={(flag) => ( - handleCreateCleanupIssue(flag)} - > + handleCreateCleanupIssue(flag)}> + Create Cleanup Issue - handleCopyCleanupPrompt(flag)} - > + handleCopyCleanupPrompt(flag)}> + Copy Cleanup AI Prompt diff --git a/frontend/web/components/release-pipelines/ReleasePipelinesList.tsx b/frontend/web/components/release-pipelines/ReleasePipelinesList.tsx index 91ae82a2e043..363c4b240f57 100644 --- a/frontend/web/components/release-pipelines/ReleasePipelinesList.tsx +++ b/frontend/web/components/release-pipelines/ReleasePipelinesList.tsx @@ -177,7 +177,6 @@ const ReleasePipelinesList = ({ history.push( @@ -185,11 +184,11 @@ const ReleasePipelinesList = ({ ) } > + Edit openChangeReleasePipelineStatusModal( @@ -199,10 +198,12 @@ const ReleasePipelinesList = ({ ) } > + {isPublished ? 'Unpublish' : 'Publish'} openModal2( 'Clone Release Pipeline', @@ -213,11 +214,11 @@ const ReleasePipelinesList = ({ ) } > + Clone @@ -230,6 +231,7 @@ const ReleasePipelinesList = ({ ) } > + Remove From dccd1b1b9123288e5ba3fc102d686253690cd98b Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Wed, 25 Nov 2026 23:11:01 -0300 Subject: [PATCH 05/12] refactor(DropdownMenu): Stretch link rows with a grid, not a child rule Co-Authored-By: Claude Opus 5.5 --- .../web/components/base/DropdownMenu/DropdownMenu.scss | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss index e44ff68aa803..ccfbdf4177b2 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss @@ -73,11 +73,10 @@ } } - // The content brings its own padding, hover and active styles + // The content brings its own padding, hover and active styles. A grid + // stretches it across the row, so all of the row is clickable &__row { - > * { - flex: 1; - } + display: grid; // A row whose content renders nothing, such as a permission check &:empty { From ce1c2ee1428be905b717d28534dc3d4c90d4f565 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Wed, 25 Nov 2026 23:24:00 -0300 Subject: [PATCH 06/12] refactor(DropdownMenu): Let states and the sheet set variables the elements read One icon colour rule, sheet sizes as variables instead of nested selectors, one gap, and the tick named __check. Co-Authored-By: Claude Opus 5.5 --- .../base/DropdownMenu/DropdownMenu.scss | 104 ++++++++---------- .../base/DropdownMenu/DropdownMenuItem.tsx | 2 +- 2 files changed, 46 insertions(+), 60 deletions(-) diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss index ccfbdf4177b2..7f853a8502ad 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss @@ -1,5 +1,11 @@ .ds-dropdown-menu { + // States and the sheet set these; the elements below only read them + --ds-dropdown-menu-row: 44px; + --ds-dropdown-menu-padding: 10px 12px; + --ds-dropdown-menu-font: var(--font-size-body-md); + --ds-dropdown-menu-reason-font: var(--font-size-body-xs); --ds-dropdown-menu-icon: 16px; + --ds-dropdown-menu-gap: 12px; display: flex; flex-direction: column; @@ -7,18 +13,31 @@ padding: 4px; min-width: 200px; + // In a bottom sheet rows are larger, like native action sheets. There is no + // 16px body token, so the size is set here + &--sheet { + --ds-dropdown-menu-row: 48px; + --ds-dropdown-menu-padding: 12px; + --ds-dropdown-menu-font: 16px; + --ds-dropdown-menu-reason-font: var(--font-size-body-sm); + --ds-dropdown-menu-icon: 20px; + } + &__item, &__row { - display: flex; - align-items: center; - min-height: 44px; + min-height: var(--ds-dropdown-menu-row); border-radius: var(--radius-md); } &__item { - gap: 12px; + --ds-dropdown-menu-icon-color: var(--color-icon-secondary); + + display: flex; + align-items: center; + gap: var(--ds-dropdown-menu-gap); width: 100%; - padding: 10px 12px; + padding: var(--ds-dropdown-menu-padding); + font-size: var(--ds-dropdown-menu-font); color: var(--color-text-default); text-align: left; @@ -33,39 +52,29 @@ // Inset, so the ring stays inside the row and keeps its corners &:focus-visible { background: var(--color-surface-hover); - border-radius: var(--radius-md); outline-offset: -2px; } &[aria-current='true'] { + --ds-dropdown-menu-icon-color: var(--color-icon-action); + font-weight: var(--font-weight-semibold); color: var(--color-text-action); background: var(--color-surface-action-subtle); - - .ds-dropdown-menu__icon, - .ds-dropdown-menu__label > svg { - color: var(--color-icon-action); - } } &--destructive { - color: var(--color-text-danger); + --ds-dropdown-menu-icon-color: var(--color-icon-danger); - .ds-dropdown-menu__icon, - .ds-dropdown-menu__label > svg { - color: var(--color-icon-danger); - } + color: var(--color-text-danger); } &[aria-disabled='true'] { + --ds-dropdown-menu-icon-color: var(--color-icon-disabled); + color: var(--color-text-disabled); cursor: not-allowed; - .ds-dropdown-menu__icon, - .ds-dropdown-menu__label > svg { - color: var(--color-icon-disabled); - } - &:hover, &:focus-visible { background: none; @@ -77,6 +86,7 @@ // stretches it across the row, so all of the row is clickable &__row { display: grid; + align-items: center; // A row whose content renders nothing, such as a permission check &:empty { @@ -95,56 +105,32 @@ &__label { display: flex; align-items: center; - gap: 12px; + gap: var(--ds-dropdown-menu-gap); + } - > svg { - flex-shrink: 0; - width: var(--ds-dropdown-menu-icon); - height: var(--ds-dropdown-menu-icon); - color: var(--color-icon-secondary); - } + &__label > svg, + &__check svg { + flex-shrink: 0; + width: var(--ds-dropdown-menu-icon); + height: var(--ds-dropdown-menu-icon); + color: var(--ds-dropdown-menu-icon-color); } // Why a disabled item can't be used; its description for screen readers &__reason { - font-size: var(--font-size-body-xs); + font-size: var(--ds-dropdown-menu-reason-font); color: var(--color-text-secondary); } // Lines up with the text, not the icon &__label:has(> svg) + &__reason { - padding-left: calc(var(--ds-dropdown-menu-icon) + 12px); + padding-left: calc( + var(--ds-dropdown-menu-icon) + var(--ds-dropdown-menu-gap) + ); } - // Icons draw with currentColor - &__icon { + // The tick on the selected item + &__check { display: flex; - flex-shrink: 0; - color: var(--color-icon-secondary); - - svg { - width: var(--ds-dropdown-menu-icon); - height: var(--ds-dropdown-menu-icon); - } - } - - // In a bottom sheet rows are larger, like native action sheets. There is no - // 16px body token, so the size is set here - &--sheet { - --ds-dropdown-menu-icon: 20px; - - .ds-dropdown-menu__item, - .ds-dropdown-menu__row { - min-height: 48px; - } - - .ds-dropdown-menu__item { - padding: 12px; - font-size: 16px; - } - - .ds-dropdown-menu__reason { - font-size: var(--font-size-body-sm); - } } } diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx index 8c1f81fb47c6..dd49203dba20 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx @@ -57,7 +57,7 @@ const DropdownMenuItem: FC = ({ )} {current && ( - + )} From fe7010e673b39effcbeff54aff4ee06dfd4684dc Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Thu, 26 Nov 2026 08:53:20 -0300 Subject: [PATCH 07/12] fix(Popover): Keep clicks from reaching the row, close on route change A popover in a clickable row (stale flags, integrations) also ran the row's click, since React bubbles through the portal. Popover now stops clicks on its trigger and inside its panel or sheet; keys still pass so Escape works. It also closes when the route changes, as the old nav overflow did, so the wrapper div in IntegrationList goes. Co-Authored-By: Claude Opus 5.5 --- frontend/web/components/IntegrationList.tsx | 34 +++++++++---------- .../base/Popover/BottomSheet/BottomSheet.tsx | 8 ++++- .../web/components/base/Popover/Popover.tsx | 16 +++++++-- .../base/Popover/stopPropagation.ts | 6 ++++ 4 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 frontend/web/components/base/Popover/stopPropagation.ts diff --git a/frontend/web/components/IntegrationList.tsx b/frontend/web/components/IntegrationList.tsx index 17a5ebc8c9ef..5183a21160c5 100644 --- a/frontend/web/components/IntegrationList.tsx +++ b/frontend/web/components/IntegrationList.tsx @@ -357,25 +357,23 @@ const Integration: FC = (props) => { integration={props.integration} /> -
e.stopPropagation()}> - + edit(integration)}> + Edit + + remove(integration)} > - edit(integration)}> - Edit - - remove(integration)} - > - Delete - - -
+ Delete +
+
))} diff --git a/frontend/web/components/base/Popover/BottomSheet/BottomSheet.tsx b/frontend/web/components/base/Popover/BottomSheet/BottomSheet.tsx index 753f1e68e46a..15b8382bd1f0 100644 --- a/frontend/web/components/base/Popover/BottomSheet/BottomSheet.tsx +++ b/frontend/web/components/base/Popover/BottomSheet/BottomSheet.tsx @@ -11,6 +11,7 @@ import { useInteractions, useRole, } from '@floating-ui/react' +import { stopPropagation } from 'components/base/Popover/stopPropagation' import './BottomSheet.scss' type BottomSheetProps = { @@ -61,7 +62,12 @@ const BottomSheet: FC = ({ return ( - + & { @@ -51,6 +53,10 @@ const Popover: FC = ({ const [isOpen, setIsOpen] = useState(false) const close = () => setIsOpen(false) const asSheet = useBreakpoint('isPhone') + // Back or forward leaves the page, so an open popover goes with it. There + // is no router in stories + const history = useHistory() + useEffect(() => history?.listen(() => setIsOpen(false)), [history]) const { context, refs, x, y } = useFloating({ middleware: [ @@ -87,7 +93,10 @@ const Popover: FC = ({ {renderTrigger( { ref: refs.setReference, - ...getReferenceProps(), + ...getReferenceProps({ + onClick: stopPropagation, + onKeyDown: stopPropagation, + }), // useRole is off for the sheet, so state the popup here ...(asSheet && { 'aria-expanded': isOpen, @@ -115,7 +124,8 @@ const Popover: FC = ({ className={classNames('ds-popover', className)} data-placement={context.placement} aria-label={ariaLabel} - {...getFloatingProps()} + // Keys pass through, so Escape still closes it + {...getFloatingProps({ onClick: stopPropagation })} > {typeof children === 'function' ? children(close) : children}
diff --git a/frontend/web/components/base/Popover/stopPropagation.ts b/frontend/web/components/base/Popover/stopPropagation.ts new file mode 100644 index 000000000000..299f372a0ffa --- /dev/null +++ b/frontend/web/components/base/Popover/stopPropagation.ts @@ -0,0 +1,6 @@ +import { SyntheticEvent } from 'react' + +// Popovers often open from a clickable row, and the panel renders in a portal +// that React still bubbles through. Clicks on the trigger or inside the panel +// must not also reach the row +export const stopPropagation = (e: SyntheticEvent) => e.stopPropagation() From 18599308ceca82782a721bd2425e40adc74a64a6 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Thu, 26 Nov 2026 08:53:24 -0300 Subject: [PATCH 08/12] test(E2E): Open feature drawer tabs by role, from More tabs when overflowed Co-Authored-By: Claude Opus 5.5 --- frontend/e2e/helpers/e2e-helpers.playwright.ts | 17 ++++++++++++++--- .../e2e/tests/environment-permission-test.pw.ts | 5 +++-- frontend/e2e/tests/experimentation-test.pw.ts | 15 +++++++++++---- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/frontend/e2e/helpers/e2e-helpers.playwright.ts b/frontend/e2e/helpers/e2e-helpers.playwright.ts index 784ef1e57e57..bb1cffe25da5 100644 --- a/frontend/e2e/helpers/e2e-helpers.playwright.ts +++ b/frontend/e2e/helpers/e2e-helpers.playwright.ts @@ -612,7 +612,7 @@ export class E2EHelpers { const dropdownSelector = byId(`select-segment-option-${selectionIndex}`); const isDropdownVisible = await this.page.locator(dropdownSelector).isVisible().catch(() => false); if (!isDropdownVisible) { - await this.click(byId('segment_overrides')); + await this.openFeatureTab('Segment Overrides'); } await this.click(dropdownSelector); await this.waitForElementVisible(this.segmentOverrideValueField(index)); @@ -638,7 +638,7 @@ export class E2EHelpers { // Add a remote config override for a segment picked by name, so other // segments in a shared project can't shift the selection async addSegmentOverrideConfigForSegment(segmentName: string, value: string) { - await this.click(byId('segment_overrides')); + await this.openFeatureTab('Segment Overrides'); // E2E builds render the select's options as plain links await this.page .locator('[data-test^="select-segment-option-"]') @@ -659,7 +659,7 @@ export class E2EHelpers { // Set segment override index (for reordering) async setSegmentOverrideIndex(index: number, newIndex: number) { - await this.click(byId('segment_overrides')); + await this.openFeatureTab('Segment Overrides'); await this.setText(byId(`sort-${index}`), `${newIndex}`); } @@ -809,6 +809,17 @@ export class E2EHelpers { throw new Error(`Try-it failed after ${maxRetries} attempts: ${key}.${field} never became ${expected}`); } + // Open a feature drawer tab, from "More tabs" when it has overflowed + async openFeatureTab(name: string) { + const tab = this.page + .getByRole('button', { name: new RegExp(`^${name}`) }) + .filter({ visible: true }); + if (!(await tab.count())) { + await this.page.getByRole('button', { exact: true, name: 'More tabs' }).click(); + } + await tab.first().click(); + } + // Go to feature versions async goToFeatureVersions(featureName: string) { await this.gotoFeature(featureName); diff --git a/frontend/e2e/tests/environment-permission-test.pw.ts b/frontend/e2e/tests/environment-permission-test.pw.ts index 7bc3a5b56ee3..8a09ae4fac32 100644 --- a/frontend/e2e/tests/environment-permission-test.pw.ts +++ b/frontend/e2e/tests/environment-permission-test.pw.ts @@ -26,6 +26,7 @@ test.describe('Environment Permission Tests', () => { gotoTraits, login, logout, + openFeatureTab, setUserPermission, toggleFeature, waitForElementClickable, @@ -100,7 +101,7 @@ test.describe('Environment Permission Tests', () => { await login(E2E_NON_ADMIN_USER_WITH_ENV_PERMISSIONS, PASSWORD) await gotoProject(PROJECT_NAME) await gotoFeature('my_feature') - await click(byId('segment_overrides')) + await openFeatureTab('Segment Overrides') await waitForElementNotClickable('#update-feature-segments-btn') await closeModal() await logout() @@ -112,7 +113,7 @@ test.describe('Environment Permission Tests', () => { await login(E2E_NON_ADMIN_USER_WITH_ENV_PERMISSIONS, PASSWORD) await gotoProject(PROJECT_NAME) await gotoFeature('my_feature') - await click(byId('segment_overrides')) + await openFeatureTab('Segment Overrides') await waitForElementClickable('#update-feature-segments-btn') await closeModal() await logout() diff --git a/frontend/e2e/tests/experimentation-test.pw.ts b/frontend/e2e/tests/experimentation-test.pw.ts index 473fa2081945..d1cf11d3e1a2 100644 --- a/frontend/e2e/tests/experimentation-test.pw.ts +++ b/frontend/e2e/tests/experimentation-test.pw.ts @@ -112,8 +112,14 @@ test.describe('Experimentation Tests', () => { page, }, testInfo) => { await skipOnSaas() - const { click, closeModal, featureValueField, gotoFeature, gotoFeatures } = - await setup(page) + const { + click, + closeModal, + featureValueField, + gotoFeature, + gotoFeatures, + openFeatureTab, + } = await setup(page) log('Create an experiment') await createExperiment(page, FIRST_EXPERIMENT) @@ -127,7 +133,7 @@ test.describe('Experimentation Tests', () => { `This flag is part of the experiment ${FIRST_EXPERIMENT}`, ) await expect(featureValueField()).not.toBeEditable() - await click(byId('segment_overrides')) + await openFeatureTab('Segment Overrides') await expect(rolloutOverride(page)).toHaveCount(1) await closeModal() }) @@ -142,6 +148,7 @@ test.describe('Experimentation Tests', () => { closeModal, gotoFeature, gotoFeatures, + openFeatureTab, waitForToast, } = await setup(page) @@ -172,7 +179,7 @@ test.describe('Experimentation Tests', () => { '100', ) await expect(page.locator(byId('featureVariationWeighta'))).toHaveValue('0') - await click(byId('segment_overrides')) + await openFeatureTab('Segment Overrides') await expectNoRolloutOverride(page) await closeModal() }) From db915a108762affa00b677d5c4efe4ad2e55f43f Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Thu, 26 Nov 2026 09:16:21 -0300 Subject: [PATCH 09/12] feat(DropdownMenu): Render overflowed nav links as menu rows The project and environment navs looked different in their overflow menus, as each kept its own link styles. DropdownMenuLink is a menu row that navigates, with the selected look for the current page; NavSubLink and SidebarLink render through it when inside a menu. DropdownMenuRow goes. Co-Authored-By: Claude Opus 5.5 --- .../base/DropdownMenu/DropdownMenu.scss | 45 +++++++++---------- .../base/DropdownMenu/DropdownMenuContext.ts | 12 +++-- .../base/DropdownMenu/DropdownMenuLink.tsx | 22 +++++++++ .../base/DropdownMenu/DropdownMenuRow.tsx | 19 -------- .../web/components/base/DropdownMenu/index.ts | 3 +- .../web/components/navigation/NavSubLink.tsx | 15 ++++++- .../web/components/navigation/OverflowNav.tsx | 7 ++- .../web/components/navigation/SidebarLink.tsx | 13 ++++++ 8 files changed, 84 insertions(+), 52 deletions(-) create mode 100644 frontend/web/components/base/DropdownMenu/DropdownMenuLink.tsx delete mode 100644 frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss index 7f853a8502ad..02c9dd3e172a 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss @@ -23,23 +23,28 @@ --ds-dropdown-menu-icon: 20px; } - &__item, - &__row { - min-height: var(--ds-dropdown-menu-row); - border-radius: var(--radius-md); - } - &__item { + --ds-dropdown-menu-text: var(--color-text-default); --ds-dropdown-menu-icon-color: var(--color-icon-secondary); display: flex; + min-height: var(--ds-dropdown-menu-row); + border-radius: var(--radius-md); align-items: center; gap: var(--ds-dropdown-menu-gap); width: 100%; padding: var(--ds-dropdown-menu-padding); font-size: var(--ds-dropdown-menu-font); - color: var(--color-text-default); text-align: left; + text-decoration: none; + + // Scoped to outrank the global link colours (body.dark a), as rows can be + // links + .ds-dropdown-menu &, + .ds-dropdown-menu &:hover, + .ds-dropdown-menu &:focus { + color: var(--ds-dropdown-menu-text); + } // Touch screens keep :hover after a tap, so only devices that can hover // get it @@ -50,29 +55,32 @@ } // Inset, so the ring stays inside the row and keeps its corners + // Set here too, as link rows don't get BareButton's ring &:focus-visible { background: var(--color-surface-hover); + outline: 2px solid var(--color-border-action); outline-offset: -2px; } - &[aria-current='true'] { + // true for a selected option, page for the current page's link + &[aria-current='true'], + &[aria-current='page'] { + --ds-dropdown-menu-text: var(--color-text-action); --ds-dropdown-menu-icon-color: var(--color-icon-action); font-weight: var(--font-weight-semibold); - color: var(--color-text-action); background: var(--color-surface-action-subtle); } &--destructive { + --ds-dropdown-menu-text: var(--color-text-danger); --ds-dropdown-menu-icon-color: var(--color-icon-danger); - - color: var(--color-text-danger); } &[aria-disabled='true'] { + --ds-dropdown-menu-text: var(--color-text-disabled); --ds-dropdown-menu-icon-color: var(--color-icon-disabled); - color: var(--color-text-disabled); cursor: not-allowed; &:hover, @@ -82,18 +90,6 @@ } } - // The content brings its own padding, hover and active styles. A grid - // stretches it across the row, so all of the row is clickable - &__row { - display: grid; - align-items: center; - - // A row whose content renders nothing, such as a permission check - &:empty { - display: none; - } - } - &__content { display: flex; flex: 1; @@ -109,6 +105,7 @@ } &__label > svg, + &__label > ion-icon, &__check svg { flex-shrink: 0; width: var(--ds-dropdown-menu-icon); diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuContext.ts b/frontend/web/components/base/DropdownMenu/DropdownMenuContext.ts index b21d4abf9f3e..98ada1b1fc1e 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenuContext.ts +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuContext.ts @@ -1,7 +1,13 @@ import { createContext, useContext } from 'react' -// Lets an item close its menu even when its handler stops the click -const DropdownMenuContext = createContext<() => void>(() => undefined) +// Holds the menu's close; null outside a menu +const DropdownMenuContext = createContext<(() => void) | null>(null) + +const noop = () => undefined export const DropdownMenuCloseProvider = DropdownMenuContext.Provider -export const useCloseDropdownMenu = () => useContext(DropdownMenuContext) +export const useCloseDropdownMenu = () => + useContext(DropdownMenuContext) ?? noop +// Nav links render as menu rows when they overflow into a menu +export const useIsInDropdownMenu = () => + useContext(DropdownMenuContext) !== null diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuLink.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenuLink.tsx new file mode 100644 index 000000000000..a29f968ec38b --- /dev/null +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuLink.tsx @@ -0,0 +1,22 @@ +import { FC, ReactNode } from 'react' +import { NavLink, NavLinkProps } from 'react-router-dom' +import { useCloseDropdownMenu } from './DropdownMenuContext' + +type DropdownMenuLinkProps = Pick & { + // The label, with an optional icon first + children: ReactNode +} + +// A menu row that navigates; the current page gets the selected look +const DropdownMenuLink: FC = ({ children, ...rest }) => { + const close = useCloseDropdownMenu() + return ( + + + {children} + + + ) +} + +export default DropdownMenuLink diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx deleted file mode 100644 index a973365af07b..000000000000 --- a/frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { FC, ReactNode } from 'react' -import { useCloseDropdownMenu } from './DropdownMenuContext' - -type DropdownMenuRowProps = { - // Content that is its own control, such as a nav link - children: ReactNode -} - -// The click comes from the link inside, which handles the keyboard itself -const DropdownMenuRow: FC = ({ children }) => { - const close = useCloseDropdownMenu() - return ( -
- {children} -
- ) -} - -export default DropdownMenuRow diff --git a/frontend/web/components/base/DropdownMenu/index.ts b/frontend/web/components/base/DropdownMenu/index.ts index 8383a60037cb..9b564469cc92 100644 --- a/frontend/web/components/base/DropdownMenu/index.ts +++ b/frontend/web/components/base/DropdownMenu/index.ts @@ -1,5 +1,6 @@ export { default } from './DropdownMenu' export { default as DropdownMenuItem } from './DropdownMenuItem' -export { default as DropdownMenuRow } from './DropdownMenuRow' +export { default as DropdownMenuLink } from './DropdownMenuLink' export type { DropdownMenuProps } from './DropdownMenu' export type { DropdownMenuItemProps } from './DropdownMenuItem' +export { useIsInDropdownMenu } from './DropdownMenuContext' diff --git a/frontend/web/components/navigation/NavSubLink.tsx b/frontend/web/components/navigation/NavSubLink.tsx index bb407abc74b7..81eb7bc1a698 100644 --- a/frontend/web/components/navigation/NavSubLink.tsx +++ b/frontend/web/components/navigation/NavSubLink.tsx @@ -3,6 +3,10 @@ import type * as H from 'history' import { LinkProps, NavLink, match } from 'react-router-dom' import { IonIcon } from '@ionic/react' import classNames from 'classnames' +import { + DropdownMenuLink, + useIsInDropdownMenu, +} from 'components/base/DropdownMenu' type NavSubLinkType = LinkProps & { icon: string | ReactNode @@ -19,6 +23,15 @@ const NavSubLink: FC = ({ isActive, ...rest }) => { + const iconNode = typeof icon === 'string' ? : icon + if (useIsInDropdownMenu()) { + return ( + + {iconNode} + {children} + + ) + } return ( = ({ className={classNames(rest.className, 'py-md-2 py-1 px-1 nav-sub-link')} >
- {typeof icon === 'string' ? : icon} + {iconNode} {children}
diff --git a/frontend/web/components/navigation/OverflowNav.tsx b/frontend/web/components/navigation/OverflowNav.tsx index 8b67ac441604..2e432832fa88 100644 --- a/frontend/web/components/navigation/OverflowNav.tsx +++ b/frontend/web/components/navigation/OverflowNav.tsx @@ -2,7 +2,7 @@ import React, { FC, ReactNode, useRef } from 'react' import { IonIcon } from '@ionic/react' import { ellipsisHorizontal } from 'ionicons/icons' import IconButton from 'components/base/IconButton' -import DropdownMenu, { DropdownMenuRow } from 'components/base/DropdownMenu' +import DropdownMenu from 'components/base/DropdownMenu' import classNames from 'classnames' import { useOverflowVisibleCount } from 'common/hooks/useOverflowVisibleCount' @@ -92,9 +92,8 @@ const OverflowNav: FC = ({ } > - {overflow.map((child, idx) => ( - {child} - ))} + {/* Nav links render as menu rows inside the menu */} + {overflow}
)} diff --git a/frontend/web/components/navigation/SidebarLink.tsx b/frontend/web/components/navigation/SidebarLink.tsx index 3a01d2e30ab0..f39794e35f41 100644 --- a/frontend/web/components/navigation/SidebarLink.tsx +++ b/frontend/web/components/navigation/SidebarLink.tsx @@ -2,6 +2,10 @@ import React, { FC, ReactNode } from 'react' import { NavLink, NavLinkProps } from 'react-router-dom' import classNames from 'classnames' import Icon, { IconName } from 'components/icons/Icon' +import { + DropdownMenuLink, + useIsInDropdownMenu, +} from 'components/base/DropdownMenu' type SidebarLinkType = Partial & { icon?: IconName @@ -18,6 +22,15 @@ const SidebarLink: FC = ({ to, ...rest }) => { + const inMenu = useIsInDropdownMenu() + if (inMenu && to) { + return ( + + {!!icon && } + {children} + + ) + } const Tag = (to ? NavLink : 'div') as any return ( From 27573268f7860ebd373cc4d3ae3555acf8b63aaf Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Thu, 26 Nov 2026 09:30:20 -0300 Subject: [PATCH 10/12] refactor(Nav): Keep ionicons out of the overflow menus Compare and the usage charts use the project's difference and bar-chart icons, and the overflow button its more-vertical dots, so no ionicon reaches a menu and DropdownMenu drops its ion-icon rule. Environments, Projects and the environment menu button keep theirs until the icon library lands. Co-Authored-By: Claude Opus 5.5 --- .../web/components/base/DropdownMenu/DropdownMenu.scss | 1 - .../web/components/navigation/EnvironmentAside.tsx | 2 +- frontend/web/components/navigation/OverflowNav.tsx | 10 +++++----- .../navigation/navbars/OrganisationNavbar.tsx | 4 ++-- .../components/navigation/navbars/ProjectNavbar.tsx | 6 +++--- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss index 02c9dd3e172a..2315babbb911 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss @@ -105,7 +105,6 @@ } &__label > svg, - &__label > ion-icon, &__check svg { flex-shrink: 0; width: var(--ds-dropdown-menu-icon); diff --git a/frontend/web/components/navigation/EnvironmentAside.tsx b/frontend/web/components/navigation/EnvironmentAside.tsx index 9aa4a5ca5b3c..0598a8aeede4 100644 --- a/frontend/web/components/navigation/EnvironmentAside.tsx +++ b/frontend/web/components/navigation/EnvironmentAside.tsx @@ -243,7 +243,7 @@ const EnvironmentAside: FC = ({ environmentId, projectId }) => { } force containerClassName='d-block d-md-none' > diff --git a/frontend/web/components/navigation/OverflowNav.tsx b/frontend/web/components/navigation/OverflowNav.tsx index 2e432832fa88..6ef6d6374412 100644 --- a/frontend/web/components/navigation/OverflowNav.tsx +++ b/frontend/web/components/navigation/OverflowNav.tsx @@ -1,7 +1,6 @@ import React, { FC, ReactNode, useRef } from 'react' -import { IonIcon } from '@ionic/react' -import { ellipsisHorizontal } from 'ionicons/icons' import IconButton from 'components/base/IconButton' +import Icon from 'components/icons/Icon' import DropdownMenu from 'components/base/DropdownMenu' import classNames from 'classnames' import { useOverflowVisibleCount } from 'common/hooks/useOverflowVisibleCount' @@ -13,7 +12,8 @@ type OverflowNavProps = { containerClassName?: string className?: string gap?: number - icon?: string + // The trigger's icon; defaults to the "more" dots + icon?: ReactNode force?: boolean } // Room for the overflow button, with some spare: nav icons load late and @@ -26,7 +26,7 @@ const OverflowNav: FC = ({ containerClassName, force, gap = 2, - icon = ellipsisHorizontal, + icon = , label, }) => { const items = React.Children.toArray( @@ -88,7 +88,7 @@ const OverflowNav: FC = ({ size='small' aria-label={label} > - + {icon} } > diff --git a/frontend/web/components/navigation/navbars/OrganisationNavbar.tsx b/frontend/web/components/navigation/navbars/OrganisationNavbar.tsx index 21f11ec0e3c5..7ac2166b5861 100644 --- a/frontend/web/components/navigation/navbars/OrganisationNavbar.tsx +++ b/frontend/web/components/navigation/navbars/OrganisationNavbar.tsx @@ -1,6 +1,6 @@ import React, { FC } from 'react' import NavSubLink from 'components/navigation/NavSubLink' -import { apps, statsChart } from 'ionicons/icons' +import { apps } from 'ionicons/icons' import Utils from 'common/utils/utils' import UsersIcon from 'components/icons/UsersIcon' import AccountStore from 'common/stores/account-store' @@ -37,7 +37,7 @@ const OrganisationNavbar: FC = ({}) => { {!Project.disableAnalytics && AccountStore.isAdmin() && ( } id='permissions-link' to={`/organisation/${AccountStore.getOrganisation().id}/usage`} > diff --git a/frontend/web/components/navigation/navbars/ProjectNavbar.tsx b/frontend/web/components/navigation/navbars/ProjectNavbar.tsx index 1b80fe8313e5..ce7d630e68ce 100644 --- a/frontend/web/components/navigation/navbars/ProjectNavbar.tsx +++ b/frontend/web/components/navigation/navbars/ProjectNavbar.tsx @@ -1,6 +1,6 @@ import React, { FC } from 'react' import NavSubLink from 'components/navigation/NavSubLink' -import { barChart, gitBranch, gitCompare } from 'ionicons/icons' +import { gitBranch } from 'ionicons/icons' import SegmentsIcon from 'components/icons/SegmentsIcon' import Permission, { useHasPermission } from 'common/providers/Permission' import AuditLogIcon from 'components/icons/AuditLogIcon' @@ -94,7 +94,7 @@ const ProjectNavbar: FC = ({ environmentId, projectId }) => { )} {projectMetricsTooltipEnabled && ( } to={`/project/${projectId}/reporting`} id='reporting-link' disabled @@ -107,7 +107,7 @@ const ProjectNavbar: FC = ({ environmentId, projectId }) => { )} } id='compare-link' to={`/project/${projectId}/compare`} > From 7e0ff4011d69bf24fb0f6e2ab3a4f60d4283c31a Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Thu, 26 Nov 2026 09:35:23 -0300 Subject: [PATCH 11/12] refactor(DropdownMenu): Simplify the menu styles Co-Authored-By: Claude Opus 5.5 --- .../base/DropdownMenu/DropdownMenu.scss | 27 +++++-------------- .../base/DropdownMenu/DropdownMenuItem.tsx | 8 +++--- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss index 2315babbb911..0d0936bbf1ef 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss @@ -1,9 +1,7 @@ .ds-dropdown-menu { // States and the sheet set these; the elements below only read them --ds-dropdown-menu-row: 44px; - --ds-dropdown-menu-padding: 10px 12px; --ds-dropdown-menu-font: var(--font-size-body-md); - --ds-dropdown-menu-reason-font: var(--font-size-body-xs); --ds-dropdown-menu-icon: 16px; --ds-dropdown-menu-gap: 12px; @@ -17,9 +15,7 @@ // 16px body token, so the size is set here &--sheet { --ds-dropdown-menu-row: 48px; - --ds-dropdown-menu-padding: 12px; --ds-dropdown-menu-font: 16px; - --ds-dropdown-menu-reason-font: var(--font-size-body-sm); --ds-dropdown-menu-icon: 20px; } @@ -33,7 +29,7 @@ align-items: center; gap: var(--ds-dropdown-menu-gap); width: 100%; - padding: var(--ds-dropdown-menu-padding); + padding: 0 12px; font-size: var(--ds-dropdown-menu-font); text-align: left; text-decoration: none; @@ -49,15 +45,14 @@ // Touch screens keep :hover after a tap, so only devices that can hover // get it @media (hover: hover) { - &:hover { + &:not([aria-disabled='true']):hover { background: var(--color-surface-hover); } } - // Inset, so the ring stays inside the row and keeps its corners - // Set here too, as link rows don't get BareButton's ring + // Inset, so the ring stays inside the row and keeps its corners. Set here + // too, as link rows don't get BareButton's ring &:focus-visible { - background: var(--color-surface-hover); outline: 2px solid var(--color-border-action); outline-offset: -2px; } @@ -82,11 +77,6 @@ --ds-dropdown-menu-icon-color: var(--color-icon-disabled); cursor: not-allowed; - - &:hover, - &:focus-visible { - background: none; - } } } @@ -105,7 +95,7 @@ } &__label > svg, - &__check svg { + &__check { flex-shrink: 0; width: var(--ds-dropdown-menu-icon); height: var(--ds-dropdown-menu-icon); @@ -114,7 +104,7 @@ // Why a disabled item can't be used; its description for screen readers &__reason { - font-size: var(--ds-dropdown-menu-reason-font); + font-size: var(--font-size-body-sm); color: var(--color-text-secondary); } @@ -124,9 +114,4 @@ var(--ds-dropdown-menu-icon) + var(--ds-dropdown-menu-gap) ); } - - // The tick on the selected item - &__check { - display: flex; - } } diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx index dd49203dba20..f7af3622dfe6 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx @@ -57,9 +57,11 @@ const DropdownMenuItem: FC = ({ )} {current && ( - - - + )} ) From be510da18baf599b4703f20ec63710aea6128e61 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Thu, 26 Nov 2026 09:38:00 -0300 Subject: [PATCH 12/12] fix(DropdownMenu): Keep a nav link's id and data-test when it overflows into the menu Co-Authored-By: Claude Opus 5.5 --- .../base/DropdownMenu/DropdownMenuLink.tsx | 21 +++++++++++-------- .../web/components/navigation/NavSubLink.tsx | 2 +- .../web/components/navigation/SidebarLink.tsx | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuLink.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenuLink.tsx index a29f968ec38b..8cf2db71c942 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenuLink.tsx +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuLink.tsx @@ -1,17 +1,20 @@ -import { FC, ReactNode } from 'react' +import { FC } from 'react' import { NavLink, NavLinkProps } from 'react-router-dom' import { useCloseDropdownMenu } from './DropdownMenuContext' -type DropdownMenuLinkProps = Pick & { - // The label, with an optional icon first - children: ReactNode -} - -// A menu row that navigates; the current page gets the selected look -const DropdownMenuLink: FC = ({ children, ...rest }) => { +// A menu row that navigates; the current page gets the selected look. +// Children are the label, with an optional icon first. +const DropdownMenuLink: FC = ({ children, onClick, ...rest }) => { const close = useCloseDropdownMenu() return ( - + { + onClick?.(e) + close() + }} + > {children} diff --git a/frontend/web/components/navigation/NavSubLink.tsx b/frontend/web/components/navigation/NavSubLink.tsx index 81eb7bc1a698..b663fb9b0251 100644 --- a/frontend/web/components/navigation/NavSubLink.tsx +++ b/frontend/web/components/navigation/NavSubLink.tsx @@ -26,7 +26,7 @@ const NavSubLink: FC = ({ const iconNode = typeof icon === 'string' ? : icon if (useIsInDropdownMenu()) { return ( - + {iconNode} {children} diff --git a/frontend/web/components/navigation/SidebarLink.tsx b/frontend/web/components/navigation/SidebarLink.tsx index f39794e35f41..7f82af842b4d 100644 --- a/frontend/web/components/navigation/SidebarLink.tsx +++ b/frontend/web/components/navigation/SidebarLink.tsx @@ -25,7 +25,7 @@ const SidebarLink: FC = ({ const inMenu = useIsInDropdownMenu() if (inMenu && to) { return ( - + {!!icon && } {children}