From 40509db38b6104a2dbdaac96d5267606c0f9540b Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Tue, 17 Nov 2026 10:55:26 -0300 Subject: [PATCH 1/4] feat(DropdownMenu): One menu component for actions, tabs and nav overflow DropdownMenu takes any element as its trigger and DropdownMenuItem children (icon, current with a tick, destructive, disabled). It is built on Popover, so menus open as a bottom sheet on phones, and items close the menu after onSelect. - Replaces the legacy items-based DropdownMenu in StaleSection, ExperimentActionDropdown, ReleasePipelinesList and IntegrationList. - Tabs overflow uses it: a "More tabs" button on desktop, and on phones the current section as a title that opens the full list. - OverflowNav uses it instead of InlineModal, with a required label so each nav's button has its own name. - TabLabel holds the tab label and unsaved-changes dot for both places. - E2E helpers find these menus by role and name instead of data-test. Co-Authored-By: Claude Opus 5.5 --- .../components/DropdownMenu.stories.tsx | 109 +++++++++++---- .../components/OverflowNav.stories.tsx | 3 + .../e2e/helpers/e2e-helpers.playwright.ts | 14 +- frontend/web/components/IntegrationList.tsx | 72 ++++++++-- frontend/web/components/base/DropdownMenu.tsx | 117 ---------------- .../base/DropdownMenu/DropdownMenu.scss | 72 ++++++++++ .../base/DropdownMenu/DropdownMenu.tsx | 36 +++++ .../base/DropdownMenu/DropdownMenuContext.ts | 7 + .../base/DropdownMenu/DropdownMenuItem.tsx | 53 +++++++ .../web/components/base/DropdownMenu/index.ts | 4 + frontend/web/components/base/Popover/index.ts | 6 +- .../ExperimentActionDropdown.tsx | 41 +++++- .../navigation/EnvironmentAside.tsx | 1 + .../web/components/navigation/OverflowNav.tsx | 61 ++++----- .../navigation/TabMenu/TabButton.tsx | 16 +-- .../components/navigation/TabMenu/TabItem.tsx | 6 +- .../navigation/TabMenu/TabLabel.tsx | 20 +++ .../components/navigation/TabMenu/Tabs.tsx | 115 ++++++++-------- .../navigation/navbars/OrganisationNavbar.tsx | 1 + .../navigation/navbars/ProjectNavbar.tsx | 1 + .../components/StaleSection.tsx | 41 ++++-- .../ReleasePipelinesList.tsx | 129 +++++++++++------- 22 files changed, 587 insertions(+), 338 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/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..bd7455801234 100644 --- a/frontend/documentation/components/DropdownMenu.stories.tsx +++ b/frontend/documentation/components/DropdownMenu.stories.tsx @@ -1,45 +1,100 @@ -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 IconButton from 'components/base/IconButton' +import Button from 'components/base/forms/Button' +import Icon from 'components/icons/Icon' -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') + chromatic: { delay: 300, viewports: [375] }, + docs: { story: { height: '420px', inline: false } }, }, - render: () => , + play: ({ canvasElement }: { canvasElement: HTMLElement }) => + openMenu(canvasElement, 'Feature actions'), + render: () => , } 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: () => ( ( ( = (props) => { } return button } - return + return ( + + + + } + > + {actions.map((action) => { + const item = ( + + {action.label} + + ) + return action.tooltip ? ( + + {action.tooltip} + + ) : ( + item + ) + })} + + ) } return ( @@ -343,19 +377,27 @@ const Integration: FC = (props) => {
e.stopPropagation()}> edit(integration), - }, - { - dataTest: 'delete-integration', - label: 'Delete', - onClick: () => remove(integration), - }, - ]} - /> + aria-label='Integration actions' + trigger={ + + + + } + > + 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..29d09e593d5a --- /dev/null +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss @@ -0,0 +1,72 @@ +.ds-dropdown-menu { + display: flex; + flex-direction: column; + padding: 4px; + min-width: 200px; + + // Plain links (e.g. nav overflow) get the same row treatment as items + > a, + &__item { + display: flex; + align-items: center; + gap: 12px; + width: 100%; + min-height: 44px; + padding: 10px 12px; + border-radius: var(--radius-md); + color: var(--color-text-default); + text-align: left; + white-space: nowrap; + } + + // Links bring their own hover and active styles + &__item:hover { + background: var(--color-surface-hover); + } + + &__label { + display: flex; + flex: 1; + align-items: center; + gap: 8px; + } + + // Icons draw with currentColor + &__icon { + display: flex; + color: var(--color-icon-secondary); + } + + &__item { + &[aria-current='true'] { + font-weight: 600; + color: var(--color-text-action); + background: var(--color-surface-action-subtle); + } + + &--destructive { + color: var(--color-text-danger); + + .ds-dropdown-menu__icon { + color: var(--color-icon-danger); + } + } + + &[aria-current='true'] .ds-dropdown-menu__icon { + color: var(--color-icon-action); + } + + &:disabled { + color: var(--color-text-disabled); + cursor: not-allowed; + + .ds-dropdown-menu__icon { + color: var(--color-icon-disabled); + } + + &:hover { + background: none; + } + } + } +} diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx b/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx new file mode 100644 index 000000000000..5ce45e076e1a --- /dev/null +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.tsx @@ -0,0 +1,36 @@ +import { cloneElement, FC, ReactElement, ReactNode } from 'react' +import Popover, { PopoverPlacement } from 'components/base/Popover' +import { DropdownMenuCloseProvider } from './DropdownMenuContext' +import './DropdownMenu.scss' + +export type DropdownMenuProps = { + 'aria-label': string + // Any element; it receives the ref and open/close props + trigger: ReactElement + children: ReactNode + placement?: PopoverPlacement +} + +const DropdownMenu: FC = ({ + 'aria-label': ariaLabel, + children, + placement = 'bottom-end', + trigger, +}) => ( + cloneElement(trigger, props)} + > + {(close) => ( + + {/* Items close the menu themselves; this covers plain links */} +
+ {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..367021fb95ff --- /dev/null +++ b/frontend/web/components/base/DropdownMenu/DropdownMenuItem.tsx @@ -0,0 +1,53 @@ +import { FC, MouseEvent, ReactNode } 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 +} + +const DropdownMenuItem: FC = ({ + children, + current = false, + destructive = false, + disabled = false, + icon, + onSelect, +}) => { + const close = useCloseDropdownMenu() + return ( + { + onSelect(e) + close() + }} + > + {icon && ( + + + + )} + {children} + {current && ( + + + + )} + + ) +} + +export default DropdownMenuItem diff --git a/frontend/web/components/base/DropdownMenu/index.ts b/frontend/web/components/base/DropdownMenu/index.ts new file mode 100644 index 000000000000..51e3f3692023 --- /dev/null +++ b/frontend/web/components/base/DropdownMenu/index.ts @@ -0,0 +1,4 @@ +export { default } from './DropdownMenu' +export { default as DropdownMenuItem } from './DropdownMenuItem' +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 802cc1e5d040..bc94b9e9f8e4 100644 --- a/frontend/web/components/experiments/ExperimentActionDropdown/ExperimentActionDropdown.tsx +++ b/frontend/web/components/experiments/ExperimentActionDropdown/ExperimentActionDropdown.tsx @@ -7,7 +7,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 IconButton from 'components/base/IconButton' +import Icon from 'components/icons/Icon' + +type ExperimentAction = { + label: string + onClick: () => void + destructive?: boolean +} type ExperimentActionDropdownProps = { experimentId: number @@ -95,13 +103,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, }, @@ -121,7 +129,7 @@ const ExperimentActionDropdown: FC = ({ case 'completed': return [ { - className: 'text-danger', + destructive: true, label: 'Delete', onClick: handleDelete, }, @@ -131,7 +139,30 @@ 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/EnvironmentAside.tsx b/frontend/web/components/navigation/EnvironmentAside.tsx index 2629c396da77..9aa4a5ca5b3c 100644 --- a/frontend/web/components/navigation/EnvironmentAside.tsx +++ b/frontend/web/components/navigation/EnvironmentAside.tsx @@ -242,6 +242,7 @@ const EnvironmentAside: FC = ({ environmentId, projectId }) => { {E2E && createEnvironmentButton} = ({ force, gap = 2, icon = ellipsisHorizontal, + label, }) => { const items = React.Children.toArray( (_children as React.ReactElement)?.props?.children || _children, @@ -30,8 +32,6 @@ 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, force, @@ -41,13 +41,6 @@ const OverflowNav: FC = ({ outerContainerRef, }) - useEffect(() => { - const unlisten = history.listen(() => { - setOpen(false) - }) - return () => unlisten() - }, [history]) - const visible = items.slice(0, visibleCount) const overflow = items.slice(visibleCount) @@ -84,31 +77,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/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..1b8eaed5a590 --- /dev/null +++ b/frontend/web/components/navigation/TabMenu/TabLabel.tsx @@ -0,0 +1,20 @@ +import { FC } from 'react' +import ColorSwatch from 'components/ColorSwatch' +import { colorIconWarning } from 'common/theme/tokens' +import { TabItemProps } from './TabItem' + +type TabLabelProps = Pick + +// A tab's label, with a dot when the tab has unsaved changes +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 5f0b25484688..2455c42dab6f 100644 --- a/frontend/web/components/navigation/TabMenu/Tabs.tsx +++ b/frontend/web/components/navigation/TabMenu/Tabs.tsx @@ -1,4 +1,6 @@ import React, { + isValidElement, + ReactElement, ReactNode, useCallback, useLayoutEffect, @@ -10,10 +12,16 @@ 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 BareButton from 'components/base/forms/BareButton' +import Icon from 'components/icons/Icon' import { useOverflowVisibleCount } from 'common/hooks/useOverflowVisibleCount' +import { useBreakpoint } from 'common/hooks/useBreakpoint' interface TabsProps { children: ReactNode | ReactNode[] @@ -48,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 @@ -74,6 +82,7 @@ const Tabs: React.FC = ({ const itemsContainerRef = useRef(null) const overflowButtonRef = useRef(null) const [overflowButtonWidth, setOverflowButtonWidth] = useState(54) // fallback + const isPhone = useBreakpoint('isPhone') useLayoutEffect(() => { if (disableOverflow) return @@ -105,6 +114,10 @@ const Tabs: React.FC = ({ [tabChildren, visibleCount, disableOverflow], ) const canGrow = !isMeasuring && visibleCount === tabChildren.length + const hasOverflow = overflow.length > 0 && !isMeasuring + const activeTab = tabChildren[value] + const tabLabelOf = (child: ReactElement) => + String(child.props.tabLabelString || child.props.tabLabel) const handleChange = useCallback( (e: React.MouseEvent, tabLabel: string, i: number) => { @@ -138,9 +151,11 @@ const Tabs: React.FC = ({ >
{(isMeasuring ? tabChildren : visible).map((child, i) => { const isSelected = !isMeasuring && value === i @@ -165,57 +180,47 @@ const Tabs: React.FC = ({ ) })}
- {overflow.length > 0 && !isMeasuring && ( -
+ + {activeTab.props.tabLabel} + + + + ) : ( + + + + ) + } > - { - 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, - ) - }, - } - })} - /> -
+ {(isPhone ? tabChildren : overflow).map((child) => { + const i = tabChildren.indexOf(child) + return ( + handleChange(e, tabLabelOf(child), i)} + > + + + ) + })} +
)} {cta &&
{cta}
} 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 ( = ({ goToPage={goToPage} renderActions={(flag) => ( handleCreateCleanupIssue(flag), - }, - { - icon: 'copy', - label: 'Copy Cleanup AI Prompt', - onClick: () => handleCopyCleanupPrompt(flag), - }, - ]} - /> + aria-label={`Actions for ${flag.name}`} + trigger={ + + + + } + > + 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..50001d8fe9da 100644 --- a/frontend/web/components/release-pipelines/ReleasePipelinesList.tsx +++ b/frontend/web/components/release-pipelines/ReleasePipelinesList.tsx @@ -2,15 +2,27 @@ 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 IconButton from 'components/base/IconButton' +import Tooltip from 'components/Tooltip' import PanelSearch from 'components/PanelSearch' import Tag from 'components/tags/Tag' -import { useEffect } from 'react' +import { ReactNode, useEffect } from 'react' import ChangeReleasePipelineStatusModal from './ChangeReleasePipelineStatusModal' import CloneReleasePipelineModal from './CloneReleasePipelineModal' import DeleteReleasePipelineModal from './DeleteReleasePipelineModal' +// Disabled actions say why on hover +const withReason = (item: ReactNode, reason?: string) => + reason ? ( + + {reason} + + ) : ( + item + ) + const NoReleasePipelines = ({ projectId }: { projectId: number }) => { const history = useHistory() @@ -182,52 +194,69 @@ const ReleasePipelinesList = ({
Features
{ + aria-label={`Actions for ${name}`} + trigger={ + + + + } + > + {withReason( + 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: () => + } + > + Edit + , + getTooltip('edit'), + )} + {withReason( + 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: () => { + ) + } + > + {isPublished ? 'Unpublish' : 'Publish'} + , + isPublished && !canUnpublish + ? 'Cannot unpublish a release pipeline with in-flight features' + : undefined, + )} + + openModal2( + 'Clone Release Pipeline', + , + ) + } + > + Clone + + {withReason( + openModal2( 'Remove Release Pipeline', , ) - }, - tooltip: canDelete - ? undefined - : 'Cannot remove a release pipeline with in-flight features', - }, - ]} - /> + } + > + Remove + , + canDelete + ? undefined + : 'Cannot remove a release pipeline with in-flight features', + )} + ) From 0c152c200e8eda509a73495e90fe018a0ae92ef3 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Tue, 17 Nov 2026 12:27:00 -0300 Subject: [PATCH 2/4] chore(Tabs): Trim comments that repeat the code Co-Authored-By: Claude Opus 5.5 --- frontend/web/components/navigation/TabMenu/TabLabel.tsx | 1 - frontend/web/components/navigation/TabMenu/Tabs.tsx | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/web/components/navigation/TabMenu/TabLabel.tsx b/frontend/web/components/navigation/TabMenu/TabLabel.tsx index 1b8eaed5a590..630bf014f9b8 100644 --- a/frontend/web/components/navigation/TabMenu/TabLabel.tsx +++ b/frontend/web/components/navigation/TabMenu/TabLabel.tsx @@ -5,7 +5,6 @@ import { TabItemProps } from './TabItem' type TabLabelProps = Pick -// A tab's label, with a dot when the tab has unsaved changes const TabLabel: FC = ({ isDirty, tabLabel }) => ( <> {tabLabel} diff --git a/frontend/web/components/navigation/TabMenu/Tabs.tsx b/frontend/web/components/navigation/TabMenu/Tabs.tsx index 2455c42dab6f..5758db8e1f15 100644 --- a/frontend/web/components/navigation/TabMenu/Tabs.tsx +++ b/frontend/web/components/navigation/TabMenu/Tabs.tsx @@ -185,8 +185,7 @@ const Tabs: React.FC = ({ aria-label='Sections' trigger={ isPhone ? ( - // Phones: the current section as a title, since the tabs no - // longer fit + // Tabs don't fit on phones, so the trigger shows the current section {activeTab.props.tabLabel} From 17383a153c9fb7429c065802bf06d00c00c2f091 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Wed, 18 Nov 2026 10:13:26 -0300 Subject: [PATCH 3/4] fix(DropdownMenu): Space menu items and keep tap highlights from sticking on touch screens Co-Authored-By: Claude Opus 5.5 --- .../base/DropdownMenu/DropdownMenu.scss | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss index 29d09e593d5a..3587ab1f2603 100644 --- a/frontend/web/components/base/DropdownMenu/DropdownMenu.scss +++ b/frontend/web/components/base/DropdownMenu/DropdownMenu.scss @@ -1,6 +1,7 @@ .ds-dropdown-menu { display: flex; flex-direction: column; + gap: 2px; padding: 4px; min-width: 200px; @@ -19,8 +20,15 @@ white-space: nowrap; } - // Links bring their own hover and active styles - &__item:hover { + // Links bring their own hover and active styles. Touch screens keep :hover + // after a tap, so only devices that can hover get it; keyboard gets focus. + @media (hover: hover) { + &__item:hover { + background: var(--color-surface-hover); + } + } + + &__item:focus-visible { background: var(--color-surface-hover); } @@ -64,7 +72,8 @@ color: var(--color-icon-disabled); } - &:hover { + &:hover, + &:focus-visible { background: none; } } From ae22fb4e5f6e665da32d17e92f9f8dff73dd9afa Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Wed, 18 Nov 2026 10:25:43 -0300 Subject: [PATCH 4/4] feat(Tabs): Scroll tabs sideways on phones instead of hiding them in a menu Co-Authored-By: Claude Opus 5.5 --- .../components/navigation/TabMenu/Tabs.tsx | 74 ++++++++++--------- .../navigation/TabMenu/useTabScroller.ts | 57 ++++++++++++++ frontend/web/styles/components/_tabs.scss | 33 +++++++++ 3 files changed, 129 insertions(+), 35 deletions(-) create mode 100644 frontend/web/components/navigation/TabMenu/useTabScroller.ts diff --git a/frontend/web/components/navigation/TabMenu/Tabs.tsx b/frontend/web/components/navigation/TabMenu/Tabs.tsx index 5758db8e1f15..1af3f044782a 100644 --- a/frontend/web/components/navigation/TabMenu/Tabs.tsx +++ b/frontend/web/components/navigation/TabMenu/Tabs.tsx @@ -18,10 +18,10 @@ import TabLabel from './TabLabel' import classNames from 'classnames' import DropdownMenu, { DropdownMenuItem } from 'components/base/DropdownMenu' import IconButton from 'components/base/IconButton' -import BareButton from 'components/base/forms/BareButton' import Icon from 'components/icons/Icon' import { useOverflowVisibleCount } from 'common/hooks/useOverflowVisibleCount' import { useBreakpoint } from 'common/hooks/useBreakpoint' +import { useTabScroller } from './useTabScroller' interface TabsProps { children: ReactNode | ReactNode[] @@ -104,18 +104,31 @@ const Tabs: React.FC = ({ outerContainerRef, }) + // Phones scroll the tabs sideways instead of hiding some behind a menu + const scrollTabs = isPhone && !disableOverflow + const { canScrollEnd, canScrollStart } = useTabScroller( + itemsContainerRef, + scrollTabs, + value, + ) + const visible = useMemo( // Disable overflow for pill tabs - () => (disableOverflow ? tabChildren : tabChildren.slice(0, visibleCount)), - [tabChildren, visibleCount, disableOverflow], + () => + disableOverflow || scrollTabs + ? tabChildren + : tabChildren.slice(0, visibleCount), + [tabChildren, visibleCount, disableOverflow, scrollTabs], ) const overflow = useMemo( - () => (disableOverflow ? [] : tabChildren.slice(visibleCount)), - [tabChildren, visibleCount, disableOverflow], + () => + disableOverflow || scrollTabs ? [] : tabChildren.slice(visibleCount), + [tabChildren, visibleCount, disableOverflow, scrollTabs], ) - const canGrow = !isMeasuring && visibleCount === tabChildren.length + const measuring = isMeasuring && !scrollTabs + const canGrow = + !scrollTabs && !isMeasuring && visibleCount === tabChildren.length const hasOverflow = overflow.length > 0 && !isMeasuring - const activeTab = tabChildren[value] const tabLabelOf = (child: ReactElement) => String(child.props.tabLabelString || child.props.tabLabel) @@ -151,14 +164,15 @@ const Tabs: React.FC = ({ >
- {(isMeasuring ? tabChildren : visible).map((child, i) => { - const isSelected = !isMeasuring && value === i + {(measuring ? tabChildren : visible).map((child, i) => { + const isSelected = !measuring && value === i return ( = ({ ) })}
- {hasOverflow && activeTab && ( + {hasOverflow && ( - - {activeTab.props.tabLabel} - - -
- ) : ( - - - - ) + + + } > - {(isPhone ? tabChildren : overflow).map((child) => { + {overflow.map((child) => { const i = tabChildren.indexOf(child) return ( , + enabled: boolean, + activeIndex: number, +): ScrollEdges => { + const [edges, setEdges] = useState({ + canScrollEnd: false, + canScrollStart: false, + }) + + useLayoutEffect(() => { + const el = ref.current + if (!enabled || !el) return + const update = () => + setEdges({ + canScrollEnd: el.scrollLeft + el.clientWidth < el.scrollWidth - 1, + canScrollStart: el.scrollLeft > 1, + }) + update() + el.addEventListener('scroll', update, { passive: true }) + const observer = + typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(update) + observer?.observe(el) + return () => { + el.removeEventListener('scroll', update) + observer?.disconnect() + } + }, [enabled, ref]) + + useEffect(() => { + const el = ref.current + const tab = el?.children.item(activeIndex) + if (!enabled || !el || !(tab instanceof HTMLElement)) return + const reduceMotion = window.matchMedia?.( + '(prefers-reduced-motion: reduce)', + ).matches + // Next frame, so the new tab's content has rendered and can't cut it short + const frame = requestAnimationFrame(() => + el.scrollTo({ + behavior: reduceMotion ? 'auto' : 'smooth', + left: tab.offsetLeft - (el.clientWidth - tab.offsetWidth) / 2, + }), + ) + return () => cancelAnimationFrame(frame) + }, [enabled, activeIndex, ref]) + + return edges +} diff --git a/frontend/web/styles/components/_tabs.scss b/frontend/web/styles/components/_tabs.scss index 9b73f1aed934..e4473671d693 100644 --- a/frontend/web/styles/components/_tabs.scss +++ b/frontend/web/styles/components/_tabs.scss @@ -55,6 +55,39 @@ flex: 1 !important; } + // Phones: tabs scroll sideways, and the edge with more tabs behind it fades + .tabs-nav__scroller { + position: relative; + overflow-x: auto; + scrollbar-width: none; + + &::-webkit-scrollbar { + display: none; + } + + > * { + flex-shrink: 0; + } + + &--fade-end { + mask-image: linear-gradient(to right, black calc(100% - 40px), transparent); + } + + &--fade-start { + mask-image: linear-gradient(to left, black calc(100% - 40px), transparent); + } + + &--fade-start.tabs-nav__scroller--fade-end { + mask-image: linear-gradient( + to right, + transparent, + black 40px, + black calc(100% - 40px), + transparent + ); + } + } + position: relative; display: flex; flex-direction: row;