Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
fix: dropdown menu position on list ittems (variables list) (#3670)
Oleg Isonen412e1cef2347
diff --git a/apps/builder/app/builder/features/settings-panel/variables-section.tsx b/apps/builder/app/builder/features/settings-panel/variables-section.tsxindex c1f61ecc57..1fc5c0378e 100644--- a/apps/builder/app/builder/features/settings-panel/variables-section.tsx+++ b/apps/builder/app/builder/features/settings-panel/variables-section.tsx@@ -194,12 +194,14 @@ const VariablesItem = ({? variable.name: `${variable.name}: ${formatValuePreview(value)}`;const [inspectDialogOpen, setInspectDialogOpen] = useState(false);+ const [isMenuOpen, setIsMenuOpen] = useState(false);return (<VariablePopoverTrigger key={variable.id} variable={variable}><CssValueListItemid={variable.id}index={index}label={<Label truncate>{label}</Label>}+ data-state={isMenuOpen ? "open" : undefined}buttons={<><ValuePreviewDialog@@ -210,7 +212,7 @@ const VariablesItem = ({>{undefined}</ValuePreviewDialog>- <DropdownMenu modal>+ <DropdownMenu modal onOpenChange={setIsMenuOpen}><DropdownMenuTrigger asChild>{/* a11y is completely broken herefocus is not restored to button invokerdiff --git a/packages/design-system/src/components/css-value-list-item.stories.tsx b/packages/design-system/src/components/css-value-list-item.stories.tsxindex 4f28991dd3..82667c027c 100644--- a/packages/design-system/src/components/css-value-list-item.stories.tsx+++ b/packages/design-system/src/components/css-value-list-item.stories.tsx@@ -3,6 +3,7 @@ import { css, styled, theme } from "../stitches.config";import {CssValueListArrowFocus,CssValueListItem,+ __testing__,} from "./css-value-list-item";import { Label, labelColors } from "./label";import { SmallToggleButton } from "./small-toggle-button";@@ -33,10 +34,6 @@ export default {title: "Library/CSS Value List Item",};-const LIST_ITEM_ATTRIBUTE = "data-list-item";--const listItemAttributes = { [LIST_ITEM_ATTRIBUTE]: true };-const Thumbnail = styled("div", {width: theme.spacing[10],height: theme.spacing[10],@@ -90,7 +87,7 @@ const ListItem = (props: {/></>}- {...listItemAttributes}+ {...__testing__.listItemAttributes}/>);};diff --git a/packages/design-system/src/components/css-value-list-item.tsx b/packages/design-system/src/components/css-value-list-item.tsxindex 4b3a00bf6c..92b7d2c839 100644--- a/packages/design-system/src/components/css-value-list-item.tsx+++ b/packages/design-system/src/components/css-value-list-item.tsx@@ -2,8 +2,6 @@ import {type ComponentProps,type Ref,forwardRef,- Children,- useMemo,type ReactNode,} from "react";import { styled } from "../stitches.config";@@ -13,8 +11,8 @@ import { theme } from "../stitches.config";import { DragHandleIcon } from "@webstudio-is/icons";import { ArrowFocus } from "./primitives/arrow-focus";-const LIST_ITEM_ATTRIBUTE = "data-list-item";-const listItemAttributes = { [LIST_ITEM_ATTRIBUTE]: true };+const listItemAttribute = "data-list-item";+const listItemAttributes = { [listItemAttribute]: true };const DragHandleIconStyled = styled(DragHandleIcon, {visibility: "hidden",@@ -40,12 +38,7 @@ const IconButtonsWrapper = styled(Flex, {top: 0,bottom: 0,paddingRight: sharedPaddingRight,- display: "none",-});--const FakeIconButtonsWrapper = styled(Flex, {- paddingLeft: theme.spacing[5],- display: "none",+ visibility: "hidden",});/**@@ -68,14 +61,11 @@ const ItemButton = styled("button", {position: "relative","&:focus-visible, &[data-focused=true], &[data-state=open]": {- [`& ${FakeIconButtonsWrapper}`]: {- display: "flex",- },[`~ ${IconButtonsWrapper}`]: {- display: "flex",+ visibility: "visible",},- "&:after": {+ "&::after": {borderRadius: theme.borderRadius[3],outline: `2px solid ${theme.colors.borderFocus}`,outlineOffset: "-2px",@@ -126,20 +116,9 @@ const ItemWrapper = styled("div", {visibility: "visible",},},- [`& ${IconButtonsWrapper}`]: {- display: "flex",- },- [`& ${FakeIconButtonsWrapper}`]: {- display: "flex",- },},});-const FakeSmallButton = styled("div", {- width: theme.spacing[9],- height: theme.spacing[9],-});-export const CssValueListItem = forwardRef(({@@ -158,18 +137,6 @@ export const CssValueListItem = forwardRef(}: Props,ref: Ref<HTMLButtonElement>) => {- const buttonsCount = Children.count(buttons?.props.children);- const fakeButtons = useMemo(- () => (- <>- {Array.from(new Array(buttonsCount), (_v, index) => (- <FakeSmallButton key={index} />- ))}- </>- ),- [buttonsCount]- );-return (<ArrowFocusrender={({ handleKeyDown }) => (@@ -202,20 +169,8 @@ export const CssValueListItem = forwardRef(</Flex><Flex grow={true} />-- {/*- We place fake divs with same dimensions as small buttons here to avoid following warning:- Warning: validateDOMNesting(...): <button> cannot appear as a descendant of <button>- Real buttons will be placed on top of fake buttons- */}- <FakeIconButtonsWrapper shrink={false} gap={2}>- {fakeButtons}- </FakeIconButtonsWrapper></ItemButton>- {/*- Real buttons are placed above ItemButton to avoid <button> cannot appear as a descendant of <button> warning- */}<IconButtonsWrapper gap={2} align="center">{buttons}</IconButtonsWrapper>@@ -249,7 +204,7 @@ export const CssValueListArrowFocus = ({if (event.key === "ArrowUp" || event.key === "ArrowDown") {handleKeyDown(event, {accept: (element) =>- element.getAttribute(LIST_ITEM_ATTRIBUTE) === "true",+ element.getAttribute(listItemAttribute) === "true",});}}}@@ -260,3 +215,7 @@ export const CssValueListArrowFocus = ({/>);};++export const __testing__ = {+ listItemAttributes,+};