From 4b611e8bc7be6d8a32d2022d895a7753298fea1f Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Wed, 25 Nov 2026 18:24:09 -0300 Subject: [PATCH 01/25] 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/25] 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/25] 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/25] 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/25] 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/25] 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/25] 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/25] 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/25] 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/25] 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/25] 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/25] 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} From 22adc4d0d2ea2ce63cdabc193105c7a610ede931 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Thu, 26 Nov 2026 09:40:16 -0300 Subject: [PATCH 13/25] fix(Nav): Stop filling the open paths of stroke icons Co-Authored-By: Claude Opus 5.5 --- frontend/web/styles/project/_project-nav.scss | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/frontend/web/styles/project/_project-nav.scss b/frontend/web/styles/project/_project-nav.scss index 1d3b3f82c594..74af0a69cd73 100644 --- a/frontend/web/styles/project/_project-nav.scss +++ b/frontend/web/styles/project/_project-nav.scss @@ -34,19 +34,16 @@ nav a { background-color: $primary-alfa-8; } } - &:hover { - svg { - path { - fill: $link-hover-color; - } - } + &:hover svg { + color: $link-hover-color; } svg { width: 14px; height: 14px; opacity: 0.6; - path { - fill: $body-color; + // Recolour filled icons; stroke icons already draw in currentColor + path[fill] { + fill: currentColor; } } ion-icon { @@ -77,11 +74,6 @@ nav a { color: $body-color-dark; } } - svg { - path { - fill: $body-color-dark; - } - } } } .border-1 { @@ -97,9 +89,6 @@ nav a { border-bottom: none !important; &.active { color: $primary; - path { - fill: $primary; - } } } .nav-modal { From b4e0acf3a4584f42986c1a662e1beeee9f1a153c Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Thu, 26 Nov 2026 17:07:05 -0300 Subject: [PATCH 14/25] refactor(Popover): Inline the stopPropagation handlers Co-Authored-By: Claude Opus 5.5 --- .../components/base/Popover/BottomSheet/BottomSheet.tsx | 3 +-- frontend/web/components/base/Popover/Popover.tsx | 9 +++++---- frontend/web/components/base/Popover/stopPropagation.ts | 6 ------ 3 files changed, 6 insertions(+), 12 deletions(-) delete mode 100644 frontend/web/components/base/Popover/stopPropagation.ts diff --git a/frontend/web/components/base/Popover/BottomSheet/BottomSheet.tsx b/frontend/web/components/base/Popover/BottomSheet/BottomSheet.tsx index 15b8382bd1f0..db53051dcb30 100644 --- a/frontend/web/components/base/Popover/BottomSheet/BottomSheet.tsx +++ b/frontend/web/components/base/Popover/BottomSheet/BottomSheet.tsx @@ -11,7 +11,6 @@ import { useInteractions, useRole, } from '@floating-ui/react' -import { stopPropagation } from 'components/base/Popover/stopPropagation' import './BottomSheet.scss' type BottomSheetProps = { @@ -66,7 +65,7 @@ const BottomSheet: FC = ({ className='ds-bottom-sheet__overlay' lockScroll // The sheet portals out of a row that may be clickable - onClick={stopPropagation} + onClick={(e) => e.stopPropagation()} > & { @@ -93,9 +92,11 @@ const Popover: FC = ({ {renderTrigger( { ref: refs.setReference, + // The trigger and panel can sit in a clickable row, and React + // bubbles portal events through it, so stop them here ...getReferenceProps({ - onClick: stopPropagation, - onKeyDown: stopPropagation, + onClick: (e) => e.stopPropagation(), + onKeyDown: (e) => e.stopPropagation(), }), // useRole is off for the sheet, so state the popup here ...(asSheet && { @@ -125,7 +126,7 @@ const Popover: FC = ({ data-placement={context.placement} aria-label={ariaLabel} // Keys pass through, so Escape still closes it - {...getFloatingProps({ onClick: stopPropagation })} + {...getFloatingProps({ onClick: (e) => e.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 deleted file mode 100644 index 299f372a0ffa..000000000000 --- a/frontend/web/components/base/Popover/stopPropagation.ts +++ /dev/null @@ -1,6 +0,0 @@ -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 9ed745cb19d604c3d02db8292ac906fcd0cab803 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Fri, 27 Nov 2026 08:57:18 -0300 Subject: [PATCH 15/25] refactor(DropdownMenu): Trim the props to a generic menu API Co-Authored-By: Claude Opus 5.5 --- .../components/DropdownMenu.stories.tsx | 4 +- frontend/web/components/IntegrationList.tsx | 2 +- .../base/DropdownMenu/DropdownMenu.scss | 6 +-- .../base/DropdownMenu/DropdownMenu.tsx | 6 +-- .../base/DropdownMenu/DropdownMenuContext.ts | 3 -- .../base/DropdownMenu/DropdownMenuItem.tsx | 41 +++++++++---------- .../base/DropdownMenu/DropdownMenuLink.tsx | 7 +++- .../web/components/base/DropdownMenu/index.ts | 1 - frontend/web/components/base/Popover/index.ts | 6 +-- .../web/components/navigation/NavSubLink.tsx | 11 +++-- .../web/components/navigation/OverflowNav.tsx | 11 +++-- .../web/components/navigation/SidebarLink.tsx | 11 +++-- .../components/navigation/TabMenu/Tabs.tsx | 16 ++++---- .../ReleasePipelinesList.tsx | 18 ++++++-- 14 files changed, 76 insertions(+), 67 deletions(-) diff --git a/frontend/documentation/components/DropdownMenu.stories.tsx b/frontend/documentation/components/DropdownMenu.stories.tsx index 4225ff760bc9..e11e810050fb 100644 --- a/frontend/documentation/components/DropdownMenu.stories.tsx +++ b/frontend/documentation/components/DropdownMenu.stories.tsx @@ -32,7 +32,7 @@ const ActionsMenu = () => ( @@ -57,7 +57,7 @@ const SectionsMenu = () => { {SECTIONS.map((section, i) => ( setCurrent(i)} > {section} diff --git a/frontend/web/components/IntegrationList.tsx b/frontend/web/components/IntegrationList.tsx index 5183a21160c5..e8d2ecb77619 100644 --- a/frontend/web/components/IntegrationList.tsx +++ b/frontend/web/components/IntegrationList.tsx @@ -279,7 +279,7 @@ const Integration: FC = (props) => { {action.label} diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss index 0d0936bbf1ef..ccacd7a6686f 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss @@ -102,14 +102,14 @@ color: var(--ds-dropdown-menu-icon-color); } - // Why a disabled item can't be used; its description for screen readers - &__reason { + // A second line under the label + &__description { font-size: var(--font-size-body-sm); color: var(--color-text-secondary); } // Lines up with the text, not the icon - &__label:has(> svg) + &__reason { + &__label:has(> svg) + &__description { padding-left: calc( var(--ds-dropdown-menu-icon) + var(--ds-dropdown-menu-gap) ); diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx index ed3e0bdc6a6b..f5a7801311bc 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx @@ -1,5 +1,5 @@ import { cloneElement, FC, ReactElement, ReactNode } from 'react' -import Popover, { PopoverPlacement } from 'components/base/Popover' +import Popover from 'components/base/Popover' import IconButton from 'components/base/IconButton' import Icon from 'components/icons/Icon' import classNames from 'classnames' @@ -14,13 +14,11 @@ export type DropdownMenuProps = { // "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 @@ -28,7 +26,7 @@ const DropdownMenu: FC = ({ return ( cloneElement( trigger ?? ( diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuContext.ts b/frontend/web/components/base/DropdownMenu/DropdownMenuContext.ts index 98ada1b1fc1e..6d327e047d3d 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenuContext.ts +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuContext.ts @@ -8,6 +8,3 @@ const noop = () => undefined export const DropdownMenuCloseProvider = DropdownMenuContext.Provider 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/DropdownMenuItem.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx index f7af3622dfe6..ca0a1f086691 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx @@ -1,4 +1,4 @@ -import { FC, MouseEvent, ReactNode, useId } from 'react' +import { FC, ReactNode, useId } from 'react' import classNames from 'classnames' import BareButton from 'components/base/forms/BareButton' import Icon from 'components/icons/Icon' @@ -7,42 +7,41 @@ import { useCloseDropdownMenu } from './DropdownMenuContext' export type DropdownMenuItemProps = { // The label, with an optional icon first: Copy children: ReactNode - onSelect: (e: MouseEvent) => void + onSelect: () => void // The selected option, as in a section switcher: ticked and announced - current?: boolean + selected?: boolean destructive?: boolean disabled?: boolean - // Shown under the label while disabled - disabledReason?: string + // A second line under the label, such as why the item is disabled + description?: string } const DropdownMenuItem: FC = ({ children, - current = false, + description, destructive = false, disabled = false, - disabledReason, onSelect, + selected = false, }) => { 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 + const descriptionId = `${id}-description` + // aria-disabled keeps the item focusable, so a disabled item's description + // still reaches keyboard and touch users. Named by the label alone, so the + // description is read once return ( { + aria-labelledby={description ? `${id}-label` : undefined} + aria-describedby={description ? descriptionId : undefined} + onClick={() => { if (disabled) return - onSelect(e) + onSelect() close() }} > @@ -50,13 +49,13 @@ const DropdownMenuItem: FC = ({ {children} - {reason && ( - - {reason} + {description && ( + + {description} )} - {current && ( + {selected && ( = ({ children, onClick, ...rest }) => { +// The row owns its styling, so it takes no className +const DropdownMenuLink: FC> = ({ + children, + onClick, + ...rest +}) => { const close = useCloseDropdownMenu() return ( = ({ children, + className, icon, isActive, ...rest }) => { const iconNode = typeof icon === 'string' ? : icon - if (useIsInDropdownMenu()) { + if (useIsInOverflowMenu()) { return ( {iconNode} @@ -37,7 +36,7 @@ const NavSubLink: FC = ({ {...rest} isActive={isActive} activeClassName='active' - className={classNames(rest.className, 'py-md-2 py-1 px-1 nav-sub-link')} + className={classNames(className, 'py-md-2 py-1 px-1 nav-sub-link')} >
{iconNode} diff --git a/frontend/web/components/navigation/OverflowNav.tsx b/frontend/web/components/navigation/OverflowNav.tsx index 6ef6d6374412..498de97a74fb 100644 --- a/frontend/web/components/navigation/OverflowNav.tsx +++ b/frontend/web/components/navigation/OverflowNav.tsx @@ -1,10 +1,14 @@ -import React, { FC, ReactNode, useRef } from 'react' +import React, { createContext, FC, ReactNode, useContext, useRef } from 'react' 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' +// Nav links render as menu rows when they overflow into the menu +const InOverflowMenuContext = createContext(false) +export const useIsInOverflowMenu = () => useContext(InOverflowMenuContext) + type OverflowNavProps = { // Names the overflow button; each nav on a page needs its own label: string @@ -92,8 +96,9 @@ const OverflowNav: FC = ({ } > - {/* Nav links render as menu rows inside the menu */} - {overflow} + + {overflow} + )}
diff --git a/frontend/web/components/navigation/SidebarLink.tsx b/frontend/web/components/navigation/SidebarLink.tsx index 7f82af842b4d..530d4010354c 100644 --- a/frontend/web/components/navigation/SidebarLink.tsx +++ b/frontend/web/components/navigation/SidebarLink.tsx @@ -2,10 +2,8 @@ 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' +import { DropdownMenuLink } from 'components/base/DropdownMenu' +import { useIsInOverflowMenu } from './OverflowNav' type SidebarLinkType = Partial & { icon?: IconName @@ -18,11 +16,12 @@ type SidebarLinkType = Partial & { const SidebarLink: FC = ({ active, children, + className, icon, to, ...rest }) => { - const inMenu = useIsInDropdownMenu() + const inMenu = useIsInOverflowMenu() if (inMenu && to) { return ( @@ -40,7 +39,7 @@ const SidebarLink: FC = ({ activeClassName='sidebar-link--active' exact={true} className={classNames( - rest.className, + className, 'sidebar-link d-flex gap-2 cursor-pointer align-items-center p-2 rounded', { 'sidebar-link--active': !to && active, diff --git a/frontend/web/components/navigation/TabMenu/Tabs.tsx b/frontend/web/components/navigation/TabMenu/Tabs.tsx index d3f509829ade..036582f0f159 100644 --- a/frontend/web/components/navigation/TabMenu/Tabs.tsx +++ b/frontend/web/components/navigation/TabMenu/Tabs.tsx @@ -104,9 +104,7 @@ const Tabs: React.FC = ({ String(child.props.tabLabelString || child.props.tabLabel) const handleChange = useCallback( - (e: React.MouseEvent, tabLabel: string, i: number) => { - e.stopPropagation() - e.preventDefault() + (tabLabel: string, i: number) => { if (urlParam) { const searchParams = new URLSearchParams(window.location.search) searchParams.set( @@ -147,9 +145,11 @@ const Tabs: React.FC = ({ isSelected={isSelected} className={canGrow ? 'tab-nav-full' : ''} noFocus={noFocus} - onClick={(e: React.MouseEvent) => - handleChange(e, tabLabelOf(child), i) - } + onClick={(e: React.MouseEvent) => { + e.stopPropagation() + e.preventDefault() + handleChange(tabLabelOf(child), i) + }} child={child} buttonTheme={buttonTheme} > @@ -177,8 +177,8 @@ const Tabs: React.FC = ({ return ( handleChange(e, tabLabelOf(child), i)} + selected={value === i} + onSelect={() => handleChange(tabLabelOf(child), i)} > history.push( @@ -188,7 +192,11 @@ const ReleasePipelinesList = ({ Edit openChangeReleasePipelineStatusModal( @@ -218,7 +226,11 @@ const ReleasePipelinesList = ({ Clone From c0c251400aa0da8169b78e01581b2f5214042f20 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Fri, 27 Nov 2026 08:59:41 -0300 Subject: [PATCH 16/25] refactor(DropdownMenu): Reuse the tab and label helpers Co-Authored-By: Claude Opus 5.5 --- frontend/e2e/helpers/e2e-helpers.playwright.ts | 9 +-------- frontend/web/components/IntegrationList.tsx | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/frontend/e2e/helpers/e2e-helpers.playwright.ts b/frontend/e2e/helpers/e2e-helpers.playwright.ts index bb1cffe25da5..68d1976d65ee 100644 --- a/frontend/e2e/helpers/e2e-helpers.playwright.ts +++ b/frontend/e2e/helpers/e2e-helpers.playwright.ts @@ -823,14 +823,7 @@ export class E2EHelpers { // Go to feature versions async goToFeatureVersions(featureName: string) { await this.gotoFeature(featureName); - // 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(); + await this.openFeatureTab('History'); } // Compare version diff --git a/frontend/web/components/IntegrationList.tsx b/frontend/web/components/IntegrationList.tsx index e8d2ecb77619..6a2b3a4cb0d0 100644 --- a/frontend/web/components/IntegrationList.tsx +++ b/frontend/web/components/IntegrationList.tsx @@ -273,7 +273,7 @@ const Integration: FC = (props) => { } return ( {actions.map((action) => ( Date: Fri, 27 Nov 2026 09:09:54 -0300 Subject: [PATCH 17/25] refactor(DropdownMenu): Share the row layout, keep trigger handlers, add menu roles and arrow keys Co-Authored-By: Claude Opus 5.5 --- .../e2e/helpers/e2e-helpers.playwright.ts | 5 +- .../base/DropdownMenu/DropdownMenu.scss | 4 +- .../base/DropdownMenu/DropdownMenu.tsx | 84 +++++++++++-------- .../base/DropdownMenu/DropdownMenuItem.tsx | 33 +++----- .../base/DropdownMenu/DropdownMenuLink.tsx | 9 +- .../base/DropdownMenu/DropdownMenuRow.tsx | 39 +++++++++ .../base/DropdownMenu/DropdownMenuTrigger.tsx | 38 +++++++++ .../DropdownMenu/__tests__/menuFocus.test.ts | 20 +++++ .../components/base/DropdownMenu/menuFocus.ts | 16 ++++ .../web/components/base/Popover/Popover.tsx | 11 ++- 10 files changed, 190 insertions(+), 69 deletions(-) create mode 100644 frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx create mode 100644 frontend/web/components/base/DropdownMenu/DropdownMenuTrigger.tsx create mode 100644 frontend/web/components/base/DropdownMenu/__tests__/menuFocus.test.ts create mode 100644 frontend/web/components/base/DropdownMenu/menuFocus.ts diff --git a/frontend/e2e/helpers/e2e-helpers.playwright.ts b/frontend/e2e/helpers/e2e-helpers.playwright.ts index 68d1976d65ee..c6181c3f6baf 100644 --- a/frontend/e2e/helpers/e2e-helpers.playwright.ts +++ b/frontend/e2e/helpers/e2e-helpers.playwright.ts @@ -811,8 +811,11 @@ export class E2EHelpers { // Open a feature drawer tab, from "More tabs" when it has overflowed async openFeatureTab(name: string) { + const label = new RegExp(`^${name}`); + // A tab is a button; in the "More tabs" menu it is an option const tab = this.page - .getByRole('button', { name: new RegExp(`^${name}`) }) + .getByRole('button', { name: label }) + .or(this.page.getByRole('menuitemradio', { name: label })) .filter({ visible: true }); if (!(await tab.count())) { await this.page.getByRole('button', { exact: true, name: 'More tabs' }).click(); diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss index ccacd7a6686f..7e5fa22b3f53 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss @@ -57,8 +57,8 @@ outline-offset: -2px; } - // true for a selected option, page for the current page's link - &[aria-current='true'], + // The chosen option, or the current page's link + &[aria-checked='true'], &[aria-current='page'] { --ds-dropdown-menu-text: var(--color-text-action); --ds-dropdown-menu-icon-color: var(--color-icon-action); diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx index f5a7801311bc..59644dd96da6 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx @@ -1,56 +1,68 @@ -import { cloneElement, FC, ReactElement, ReactNode } from 'react' +import { FC, KeyboardEvent, ReactElement, ReactNode } from 'react' import Popover 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 DropdownMenuTrigger from './DropdownMenuTrigger' +import { nextMenuIndex } from './menuFocus' 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. + // Any element; it keeps its own handlers and ref. Defaults to a "more" + // button. trigger?: ReactElement children: ReactNode } +// Arrow keys, Home and End move focus between the rows +const moveFocus = (e: KeyboardEvent) => { + const rows = Array.from( + e.currentTarget.querySelectorAll('.ds-dropdown-menu__item'), + ) + const index = rows.findIndex((row) => row === document.activeElement) + const next = nextMenuIndex(e.key, index, rows.length) + if (next === null || !rows.length) return + e.preventDefault() + rows[next].focus() +} + const DropdownMenu: FC = ({ 'aria-label': ariaLabel, children, trigger, -}) => { - // Popover opens as a sheet on the same breakpoint, where rows get larger - const asSheet = useBreakpoint('isPhone') - return ( - - cloneElement( - trigger ?? ( - - - - ), - props, - ) - } - > - {(close) => ( - -
- {children} -
-
- )} -
- ) -} +}) => ( + ( + + {trigger ?? ( + + + + )} + + )} + > + {(close, asSheet) => ( + +
+ {children} +
+
+ )} +
+) export default DropdownMenu diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx index ca0a1f086691..72693e7332a9 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx @@ -1,14 +1,14 @@ import { FC, ReactNode, useId } from 'react' import classNames from 'classnames' import BareButton from 'components/base/forms/BareButton' -import Icon from 'components/icons/Icon' import { useCloseDropdownMenu } from './DropdownMenuContext' +import DropdownMenuRow from './DropdownMenuRow' export type DropdownMenuItemProps = { // The label, with an optional icon first: Copy children: ReactNode onSelect: () => void - // The selected option, as in a section switcher: ticked and announced + // Makes the item one option of a single choice, ticked when true selected?: boolean destructive?: boolean disabled?: boolean @@ -22,11 +22,11 @@ const DropdownMenuItem: FC = ({ destructive = false, disabled = false, onSelect, - selected = false, + selected, }) => { const close = useCloseDropdownMenu() const id = useId() - const descriptionId = `${id}-description` + const isOption = selected !== undefined // aria-disabled keeps the item focusable, so a disabled item's description // still reaches keyboard and touch users. Named by the label alone, so the // description is read once @@ -35,33 +35,20 @@ const DropdownMenuItem: FC = ({ className={classNames('ds-dropdown-menu__item', { 'ds-dropdown-menu__item--destructive': destructive, })} - aria-current={selected || undefined} + role={isOption ? 'menuitemradio' : 'menuitem'} + aria-checked={isOption ? selected : undefined} aria-disabled={disabled || undefined} aria-labelledby={description ? `${id}-label` : undefined} - aria-describedby={description ? descriptionId : undefined} + aria-describedby={description ? `${id}-description` : undefined} onClick={() => { if (disabled) return onSelect() close() }} > - - - {children} - - {description && ( - - {description} - - )} - - {selected && ( - - )} + + {children} +
) } diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuLink.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenuLink.tsx index b6cfdb247465..9909ac775470 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenuLink.tsx +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuLink.tsx @@ -1,6 +1,7 @@ -import { FC } from 'react' +import { FC, useId } from 'react' import { NavLink, NavLinkProps } from 'react-router-dom' import { useCloseDropdownMenu } from './DropdownMenuContext' +import DropdownMenuRow from './DropdownMenuRow' // A menu row that navigates; the current page gets the selected look. // Children are the label, with an optional icon first. @@ -11,18 +12,18 @@ const DropdownMenuLink: FC> = ({ ...rest }) => { const close = useCloseDropdownMenu() + const id = useId() return ( { onClick?.(e) close() }} > - - {children} - + {children} ) } diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx new file mode 100644 index 000000000000..9e6b6d981c49 --- /dev/null +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx @@ -0,0 +1,39 @@ +import { FC, ReactNode } from 'react' +import Icon from 'components/icons/Icon' + +type DropdownMenuRowProps = { + // Prefix for the label and description ids + id: string + children: ReactNode + description?: string + selected?: boolean +} + +// The inside of a menu row, shared by items and links +const DropdownMenuRow: FC = ({ + children, + description, + id, + selected, +}) => ( + <> + + + {children} + + {description && ( + + {description} + + )} + + {selected && ( + + )} + +) + +export default DropdownMenuRow diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuTrigger.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenuTrigger.tsx new file mode 100644 index 000000000000..10d208b81fec --- /dev/null +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuTrigger.tsx @@ -0,0 +1,38 @@ +import { cloneElement, FC, ReactElement, Ref } from 'react' +import { useMergeRefs } from '@floating-ui/react' +import { PopoverTriggerProps } from 'components/base/Popover' + +type TriggerProps = Record & { ref?: Ref } + +type DropdownMenuTriggerProps = { + children: ReactElement + popoverProps: PopoverTriggerProps +} + +// Gives the trigger the popover's props without dropping its own handlers +// or ref: both run, the trigger's first +const DropdownMenuTrigger: FC = ({ + children, + popoverProps, +}) => { + const own = children.props + const ref = useMergeRefs([popoverProps.ref, own.ref]) + const props = Object.fromEntries( + Object.entries(popoverProps).map(([key, value]) => { + const ownValue = own[key] + if (typeof value !== 'function' || typeof ownValue !== 'function') { + return [key, value] + } + return [ + key, + (...args: unknown[]) => { + ownValue(...args) + value(...args) + }, + ] + }), + ) + return cloneElement(children, { ...props, ref }) +} + +export default DropdownMenuTrigger diff --git a/frontend/web/components/base/DropdownMenu/__tests__/menuFocus.test.ts b/frontend/web/components/base/DropdownMenu/__tests__/menuFocus.test.ts new file mode 100644 index 000000000000..afaf53850618 --- /dev/null +++ b/frontend/web/components/base/DropdownMenu/__tests__/menuFocus.test.ts @@ -0,0 +1,20 @@ +import { nextMenuIndex } from 'components/base/DropdownMenu/menuFocus' + +describe('nextMenuIndex', () => { + it.each` + key | index | count | expected + ${'ArrowDown'} | ${0} | ${3} | ${1} + ${'ArrowDown'} | ${2} | ${3} | ${0} + ${'ArrowUp'} | ${1} | ${3} | ${0} + ${'ArrowUp'} | ${0} | ${3} | ${2} + ${'ArrowUp'} | ${-1} | ${3} | ${2} + ${'Home'} | ${2} | ${3} | ${0} + ${'End'} | ${0} | ${3} | ${2} + ${'Tab'} | ${0} | ${3} | ${null} + `( + '$key from $index of $count: $expected', + ({ count, expected, index, key }) => { + expect(nextMenuIndex(key, index, count)).toBe(expected) + }, + ) +}) diff --git a/frontend/web/components/base/DropdownMenu/menuFocus.ts b/frontend/web/components/base/DropdownMenu/menuFocus.ts new file mode 100644 index 000000000000..2a4df00f96eb --- /dev/null +++ b/frontend/web/components/base/DropdownMenu/menuFocus.ts @@ -0,0 +1,16 @@ +type Move = (index: number, count: number) => number + +// Where each key moves focus, wrapping at either end +const MOVES: Partial> = { + ArrowDown: (index, count) => (index + 1) % count, + ArrowUp: (index, count) => (index <= 0 ? count - 1 : index - 1), + End: (_, count) => count - 1, + Home: () => 0, +} + +// The row a key moves focus to; null for keys that don't move it +export const nextMenuIndex = ( + key: string, + index: number, + count: number, +): number | null => MOVES[key]?.(index, count) ?? null diff --git a/frontend/web/components/base/Popover/Popover.tsx b/frontend/web/components/base/Popover/Popover.tsx index 12c23c0f30e8..d753153fd6dd 100644 --- a/frontend/web/components/base/Popover/Popover.tsx +++ b/frontend/web/components/base/Popover/Popover.tsx @@ -36,7 +36,8 @@ const WINDOW_PADDING = 8 export type PopoverProps = { 'aria-label': string renderTrigger: (props: PopoverTriggerProps, isOpen: boolean) => ReactNode - children: ReactNode | ((close: () => void) => ReactNode) + // A function gets close, and whether the panel is the phone sheet + children: ReactNode | ((close: () => void, asSheet: boolean) => ReactNode) placement?: PopoverPlacement // Applies to the desktop panel only; the phone sheet sizes itself. className?: string @@ -109,7 +110,9 @@ const Popover: FC = ({ {asSheet ? ( {isOpen && - (typeof children === 'function' ? children(close) : children)} + (typeof children === 'function' + ? children(close, asSheet) + : children)} ) : ( isOpen && ( @@ -128,7 +131,9 @@ const Popover: FC = ({ // Keys pass through, so Escape still closes it {...getFloatingProps({ onClick: (e) => e.stopPropagation() })} > - {typeof children === 'function' ? children(close) : children} + {typeof children === 'function' + ? children(close, asSheet) + : children}
From 9186dd11168c2fa53af7ec08206201230b8c1ba0 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Fri, 27 Nov 2026 09:12:44 -0300 Subject: [PATCH 18/25] fix(DropdownMenu): Announce the popup as a menu and keep one Tab stop Co-Authored-By: Claude Opus 5.5 --- .../base/DropdownMenu/DropdownMenu.tsx | 29 +++++++++++++++---- .../web/components/base/Popover/Popover.tsx | 8 +++-- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx index 59644dd96da6..fbbc29ce28e0 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx @@ -17,15 +17,29 @@ export type DropdownMenuProps = { children: ReactNode } -// Arrow keys, Home and End move focus between the rows -const moveFocus = (e: KeyboardEvent) => { - const rows = Array.from( - e.currentTarget.querySelectorAll('.ds-dropdown-menu__item'), +const rowsOf = (menu: HTMLElement) => + Array.from(menu.querySelectorAll('.ds-dropdown-menu__item')) + +// One row is the menu's Tab stop: the chosen option, else the first +const setTabStop = (menu: HTMLElement | null) => { + if (!menu) return + const rows = rowsOf(menu) + const stop = Math.max( + rows.findIndex((row) => row.getAttribute('aria-checked') === 'true'), + 0, ) + rows.forEach((row, i) => (row.tabIndex = i === stop ? 0 : -1)) +} + +// Arrow keys, Home and End move focus between the rows, and the Tab stop +// moves with it +const moveFocus = (e: KeyboardEvent) => { + const rows = rowsOf(e.currentTarget) const index = rows.findIndex((row) => row === document.activeElement) const next = nextMenuIndex(e.key, index, rows.length) if (next === null || !rows.length) return e.preventDefault() + rows.forEach((row, i) => (row.tabIndex = i === next ? 0 : -1)) rows[next].focus() } @@ -37,6 +51,7 @@ const DropdownMenu: FC = ({ ( {trigger ?? ( @@ -50,8 +65,10 @@ const DropdownMenu: FC = ({ {(close, asSheet) => (
void, asSheet: boolean) => ReactNode) placement?: PopoverPlacement + // What the panel is, announced on the trigger. The phone sheet is always a + // dialog; a menu goes inside it + role?: 'dialog' | 'menu' // Applies to the desktop panel only; the phone sheet sizes itself. className?: string } @@ -49,6 +52,7 @@ const Popover: FC = ({ className, placement = 'bottom-start', renderTrigger, + role = 'dialog', }) => { const [isOpen, setIsOpen] = useState(false) const close = () => setIsOpen(false) @@ -85,7 +89,7 @@ const Popover: FC = ({ useClick(context), // The sheet handles its own dismiss and role useDismiss(context, { enabled: !asSheet }), - useRole(context, { enabled: !asSheet }), + useRole(context, { enabled: !asSheet, role }), ]) return ( @@ -102,7 +106,7 @@ const Popover: FC = ({ // useRole is off for the sheet, so state the popup here ...(asSheet && { 'aria-expanded': isOpen, - 'aria-haspopup': 'dialog', + 'aria-haspopup': role, }), }, isOpen, From 4bc9fd60dde3d2d13b3523b2bc8f35f52d33b056 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Fri, 27 Nov 2026 09:13:21 -0300 Subject: [PATCH 19/25] refactor(DropdownMenu): Find menu rows by role Co-Authored-By: Claude Opus 5.5 --- frontend/web/components/base/DropdownMenu/DropdownMenu.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx index fbbc29ce28e0..4544b16e81ef 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx @@ -18,7 +18,7 @@ export type DropdownMenuProps = { } const rowsOf = (menu: HTMLElement) => - Array.from(menu.querySelectorAll('.ds-dropdown-menu__item')) + Array.from(menu.querySelectorAll('[role^="menuitem"]')) // One row is the menu's Tab stop: the chosen option, else the first const setTabStop = (menu: HTMLElement | null) => { From edbe35765de96165f049f464d031e8598f974986 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Fri, 27 Nov 2026 09:18:00 -0300 Subject: [PATCH 20/25] fix(DropdownMenu): Wait for the menu role in the stories Co-Authored-By: Claude Opus 5.5 --- frontend/documentation/components/DropdownMenu.stories.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/documentation/components/DropdownMenu.stories.tsx b/frontend/documentation/components/DropdownMenu.stories.tsx index e11e810050fb..c3ce0a81e693 100644 --- a/frontend/documentation/components/DropdownMenu.stories.tsx +++ b/frontend/documentation/components/DropdownMenu.stories.tsx @@ -70,7 +70,7 @@ const SectionsMenu = () => { const openMenu = async (canvasElement: HTMLElement, name: string) => { const canvas = within(canvasElement) await userEvent.click(canvas.getByRole('button', { name })) - await screen.findByRole('dialog') + await screen.findByRole('menu') } export const Actions: Story = { From 84fa2e49d15db7137fb2f4d23cb0e82a73819350 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Fri, 27 Nov 2026 09:25:51 -0300 Subject: [PATCH 21/25] fix(DropdownMenu): Let Space choose a link row Co-Authored-By: Claude Opus 5.5 --- .../components/base/DropdownMenu/DropdownMenuLink.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuLink.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenuLink.tsx index 9909ac775470..021749971663 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenuLink.tsx +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuLink.tsx @@ -9,6 +9,7 @@ import DropdownMenuRow from './DropdownMenuRow' const DropdownMenuLink: FC> = ({ children, onClick, + onKeyDown, ...rest }) => { const close = useCloseDropdownMenu() @@ -22,6 +23,14 @@ const DropdownMenuLink: FC> = ({ onClick?.(e) close() }} + // Menu rows answer Space like Enter; a link only answers Enter + onKeyDown={(e) => { + onKeyDown?.(e) + if (e.key === ' ') { + e.preventDefault() + e.currentTarget.click() + } + }} > {children} From d3780474c198714b31562ae5dc46110f25da9464 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Fri, 27 Nov 2026 09:26:37 -0300 Subject: [PATCH 22/25] chore(DropdownMenu): Trim the comments Co-Authored-By: Claude Opus 5.5 --- frontend/e2e/helpers/e2e-helpers.playwright.ts | 1 - .../web/components/base/DropdownMenu/DropdownMenu.scss | 7 +------ frontend/web/components/base/DropdownMenu/DropdownMenu.tsx | 6 +----- .../components/base/DropdownMenu/DropdownMenuContext.ts | 1 - .../web/components/base/DropdownMenu/DropdownMenuItem.tsx | 6 ++---- .../web/components/base/DropdownMenu/DropdownMenuLink.tsx | 2 -- .../web/components/base/DropdownMenu/DropdownMenuRow.tsx | 1 - frontend/web/components/base/DropdownMenu/menuFocus.ts | 2 -- frontend/web/components/base/Popover/Popover.tsx | 6 ++---- frontend/web/components/navigation/OverflowNav.tsx | 1 - 10 files changed, 6 insertions(+), 27 deletions(-) diff --git a/frontend/e2e/helpers/e2e-helpers.playwright.ts b/frontend/e2e/helpers/e2e-helpers.playwright.ts index c6181c3f6baf..e3ae0c8ad637 100644 --- a/frontend/e2e/helpers/e2e-helpers.playwright.ts +++ b/frontend/e2e/helpers/e2e-helpers.playwright.ts @@ -809,7 +809,6 @@ 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 label = new RegExp(`^${name}`); // A tab is a button; in the "More tabs" menu it is an option diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss index 7e5fa22b3f53..0a057b01cd39 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss @@ -1,5 +1,4 @@ .ds-dropdown-menu { - // States and the sheet set these; the elements below only read them --ds-dropdown-menu-row: 44px; --ds-dropdown-menu-font: var(--font-size-body-md); --ds-dropdown-menu-icon: 16px; @@ -11,8 +10,7 @@ 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 + // There is no 16px body token &--sheet { --ds-dropdown-menu-row: 48px; --ds-dropdown-menu-font: 16px; @@ -57,7 +55,6 @@ outline-offset: -2px; } - // The chosen option, or the current page's link &[aria-checked='true'], &[aria-current='page'] { --ds-dropdown-menu-text: var(--color-text-action); @@ -87,7 +84,6 @@ min-width: 0; } - // The label and an optional icon before it &__label { display: flex; align-items: center; @@ -102,7 +98,6 @@ color: var(--ds-dropdown-menu-icon-color); } - // A second line under the label &__description { font-size: var(--font-size-body-sm); color: var(--color-text-secondary); diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx index 4544b16e81ef..d11a42831c94 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx @@ -11,8 +11,7 @@ import './DropdownMenu.scss' export type DropdownMenuProps = { // Names the menu, and the default trigger 'aria-label': string - // Any element; it keeps its own handlers and ref. Defaults to a "more" - // button. + // Keeps its own handlers and ref trigger?: ReactElement children: ReactNode } @@ -31,8 +30,6 @@ const setTabStop = (menu: HTMLElement | null) => { rows.forEach((row, i) => (row.tabIndex = i === stop ? 0 : -1)) } -// Arrow keys, Home and End move focus between the rows, and the Tab stop -// moves with it const moveFocus = (e: KeyboardEvent) => { const rows = rowsOf(e.currentTarget) const index = rows.findIndex((row) => row === document.activeElement) @@ -70,7 +67,6 @@ const DropdownMenu: FC = ({ role={asSheet ? 'menu' : undefined} aria-label={asSheet ? ariaLabel : undefined} className={classNames('ds-dropdown-menu', { - // Larger rows in the phone sheet 'ds-dropdown-menu--sheet': asSheet, })} onKeyDown={moveFocus} diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuContext.ts b/frontend/web/components/base/DropdownMenu/DropdownMenuContext.ts index 6d327e047d3d..5e1bfe6688bc 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenuContext.ts +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuContext.ts @@ -1,6 +1,5 @@ import { createContext, useContext } from 'react' -// Holds the menu's close; null outside a menu const DropdownMenuContext = createContext<(() => void) | null>(null) const noop = () => undefined diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx index 72693e7332a9..f76abf28c331 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx @@ -12,7 +12,6 @@ export type DropdownMenuItemProps = { selected?: boolean destructive?: boolean disabled?: boolean - // A second line under the label, such as why the item is disabled description?: string } @@ -27,9 +26,8 @@ const DropdownMenuItem: FC = ({ const close = useCloseDropdownMenu() const id = useId() const isOption = selected !== undefined - // aria-disabled keeps the item focusable, so a disabled item's description - // still reaches keyboard and touch users. Named by the label alone, so the - // description is read once + // aria-disabled keeps it focusable, so the description stays reachable. + // Named by the label alone, so the description is read once return ( > = ({ children, diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx index 9e6b6d981c49..440c1a5fcd82 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx @@ -9,7 +9,6 @@ type DropdownMenuRowProps = { selected?: boolean } -// The inside of a menu row, shared by items and links const DropdownMenuRow: FC = ({ children, description, diff --git a/frontend/web/components/base/DropdownMenu/menuFocus.ts b/frontend/web/components/base/DropdownMenu/menuFocus.ts index 2a4df00f96eb..56eb5294520d 100644 --- a/frontend/web/components/base/DropdownMenu/menuFocus.ts +++ b/frontend/web/components/base/DropdownMenu/menuFocus.ts @@ -1,6 +1,5 @@ type Move = (index: number, count: number) => number -// Where each key moves focus, wrapping at either end const MOVES: Partial> = { ArrowDown: (index, count) => (index + 1) % count, ArrowUp: (index, count) => (index <= 0 ? count - 1 : index - 1), @@ -8,7 +7,6 @@ const MOVES: Partial> = { Home: () => 0, } -// The row a key moves focus to; null for keys that don't move it export const nextMenuIndex = ( key: string, index: number, diff --git a/frontend/web/components/base/Popover/Popover.tsx b/frontend/web/components/base/Popover/Popover.tsx index 81e0782be8e4..8d2a88c15c10 100644 --- a/frontend/web/components/base/Popover/Popover.tsx +++ b/frontend/web/components/base/Popover/Popover.tsx @@ -39,8 +39,7 @@ export type PopoverProps = { // A function gets close, and whether the panel is the phone sheet children: ReactNode | ((close: () => void, asSheet: boolean) => ReactNode) placement?: PopoverPlacement - // What the panel is, announced on the trigger. The phone sheet is always a - // dialog; a menu goes inside it + // The phone sheet is always a dialog; a menu goes inside it role?: 'dialog' | 'menu' // Applies to the desktop panel only; the phone sheet sizes itself. className?: string @@ -57,8 +56,7 @@ 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 + // Close on a route change. Stories have no router const history = useHistory() useEffect(() => history?.listen(() => setIsOpen(false)), [history]) diff --git a/frontend/web/components/navigation/OverflowNav.tsx b/frontend/web/components/navigation/OverflowNav.tsx index 498de97a74fb..8c943a5b2b16 100644 --- a/frontend/web/components/navigation/OverflowNav.tsx +++ b/frontend/web/components/navigation/OverflowNav.tsx @@ -16,7 +16,6 @@ type OverflowNavProps = { containerClassName?: string className?: string gap?: number - // The trigger's icon; defaults to the "more" dots icon?: ReactNode force?: boolean } From 4a9511c81624e60816c48f8535d3bd9dccd43761 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Fri, 27 Nov 2026 09:37:11 -0300 Subject: [PATCH 23/25] refactor(Popover): Close on back or forward without the router Co-Authored-By: Claude Opus 5.5 --- frontend/web/components/base/Popover/Popover.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/web/components/base/Popover/Popover.tsx b/frontend/web/components/base/Popover/Popover.tsx index 8d2a88c15c10..3a9ee2f08e57 100644 --- a/frontend/web/components/base/Popover/Popover.tsx +++ b/frontend/web/components/base/Popover/Popover.tsx @@ -1,5 +1,4 @@ import { FC, ReactNode, useEffect, useState } from 'react' -import { useHistory } from 'react-router-dom' import classNames from 'classnames' import { autoUpdate, @@ -56,9 +55,12 @@ const Popover: FC = ({ const [isOpen, setIsOpen] = useState(false) const close = () => setIsOpen(false) const asSheet = useBreakpoint('isPhone') - // Close on a route change. Stories have no router - const history = useHistory() - useEffect(() => history?.listen(() => setIsOpen(false)), [history]) + // Back or forward closes it; navigating from inside closes it already + useEffect(() => { + const closeOnPop = () => setIsOpen(false) + window.addEventListener('popstate', closeOnPop) + return () => window.removeEventListener('popstate', closeOnPop) + }, []) const { context, refs, x, y } = useFloating({ middleware: [ From e37e6ed31a492a102d1f5743cd2dd6bae148c723 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Fri, 27 Nov 2026 09:42:45 -0300 Subject: [PATCH 24/25] style(DropdownMenu): Use 36px rows on desktop Co-Authored-By: Claude Opus 5.5 --- frontend/web/components/base/DropdownMenu/DropdownMenu.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss index 0a057b01cd39..aed545f22773 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss @@ -1,5 +1,5 @@ .ds-dropdown-menu { - --ds-dropdown-menu-row: 44px; + --ds-dropdown-menu-row: 36px; --ds-dropdown-menu-font: var(--font-size-body-md); --ds-dropdown-menu-icon: 16px; --ds-dropdown-menu-gap: 12px; @@ -27,7 +27,7 @@ align-items: center; gap: var(--ds-dropdown-menu-gap); width: 100%; - padding: 0 12px; + padding: 6px 12px; font-size: var(--ds-dropdown-menu-font); text-align: left; text-decoration: none; From 421f69affd64f3c97fc9d101300744db1acf99a1 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Fri, 27 Nov 2026 09:51:29 -0300 Subject: [PATCH 25/25] refactor(DropdownMenu): Use BodyText for the item description Co-Authored-By: Claude Opus 5.5 --- .../web/components/base/DropdownMenu/DropdownMenu.scss | 5 ----- .../web/components/base/DropdownMenu/DropdownMenuRow.tsx | 8 ++++++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss index aed545f22773..f7470d8014cc 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss @@ -98,11 +98,6 @@ color: var(--ds-dropdown-menu-icon-color); } - &__description { - font-size: var(--font-size-body-sm); - color: var(--color-text-secondary); - } - // Lines up with the text, not the icon &__label:has(> svg) + &__description { padding-left: calc( diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx index 440c1a5fcd82..8b53f3c247da 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuRow.tsx @@ -1,5 +1,6 @@ import { FC, ReactNode } from 'react' import Icon from 'components/icons/Icon' +import { BodyText } from 'components/base/typography' type DropdownMenuRowProps = { // Prefix for the label and description ids @@ -21,12 +22,15 @@ const DropdownMenuRow: FC = ({ {children} {description && ( - {description} - + )} {selected && (