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: Add source and reset details in tooltips for flex gap (#2752)
Jaya Krishna Namburu93c9defb90c9
diff --git a/apps/builder/app/builder/features/style-panel/sections/layout/layout.tsx b/apps/builder/app/builder/features/style-panel/sections/layout/layout.tsxindex 0405c15cf2..ecb79ff93e 100644--- a/apps/builder/app/builder/features/style-panel/sections/layout/layout.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/layout/layout.tsx@@ -33,6 +33,7 @@ import {} from "../../shared/css-value-input";import { theme } from "@webstudio-is/design-system";import { isFeatureEnabled } from "@webstudio-is/feature-flags";+import { TooltipContent } from "../../../style-panel/shared/property-name";const GapLinked = ({isLinked,@@ -59,6 +60,7 @@ const GapInput = ({onIntermediateChange,onPreviewChange,onChange,+ onReset,}: {icon: JSX.Element;style: StyleInfo;@@ -67,14 +69,29 @@ const GapInput = ({onIntermediateChange: (value?: StyleValue | IntermediateStyleValue) => void;onPreviewChange: (value?: StyleValue) => void;onChange: (value: StyleValue) => void;+ onReset: () => void;}) => {const { label, items } = styleConfigByName(property);+return (<Box><CssValueInputstyleSource={getStyleSource(style[property])}- icon={<EnhancedTooltip content={label}>{icon}</EnhancedTooltip>}- property="columnGap"+ icon={+ <EnhancedTooltip+ content={+ <TooltipContent+ title={label}+ style={style}+ properties={[property]}+ onReset={onReset}+ />+ }+ >+ {icon}+ </EnhancedTooltip>+ }+ property={property}value={style[property]?.value}intermediateValue={intermediateValue}keywords={items.map((item) => ({@@ -168,6 +185,13 @@ const FlexGap = ({setIntermediateRowGap(value);}}}+ onReset={() => {+ batchUpdate.deleteProperty("columnGap");+ if (isLinked) {+ batchUpdate.deleteProperty("rowGap");+ }+ batchUpdate.publish();+ }}onPreviewChange={(value) => {if (value === undefined) {batchUpdate.deleteProperty("columnGap");@@ -229,6 +253,13 @@ const FlexGap = ({setIntermediateColumnGap(value);}}}+ onReset={() => {+ batchUpdate.deleteProperty("rowGap");+ if (isLinked) {+ batchUpdate.deleteProperty("columnGap");+ }+ batchUpdate.publish();+ }}onPreviewChange={(value) => {if (value === undefined) {batchUpdate.deleteProperty("rowGap");diff --git a/apps/builder/app/builder/features/style-panel/shared/property-name.tsx b/apps/builder/app/builder/features/style-panel/shared/property-name.tsxindex d56ba21626..78523811d4 100644--- a/apps/builder/app/builder/features/style-panel/shared/property-name.tsx+++ b/apps/builder/app/builder/features/style-panel/shared/property-name.tsx@@ -125,7 +125,7 @@ const getDescription = (properties: StyleProperty[]) => {return propertyDescriptions[property as keyof typeof propertyDescriptions];};-const TooltipContent = ({+export const TooltipContent = ({title,description,scrollableContent,diff --git a/packages/design-system/src/components/enhanced-tooltip.tsx b/packages/design-system/src/components/enhanced-tooltip.tsxindex e2e18061e4..758c7a6cc7 100644--- a/packages/design-system/src/components/enhanced-tooltip.tsx+++ b/packages/design-system/src/components/enhanced-tooltip.tsx@@ -89,7 +89,7 @@ export const EnhancedTooltip = forwardRef(// We debounce blur/focus events in a single function, to skip fast `blur/focus` which can occur during select menu hoversconst handleFocusEventsDebounced = useDebouncedCallback(- (eventType: "focus" | "blur") => {+ (eventType: "focus" | "blur" | "mouseLeave") => {if (eventType === "blur") {isFocusedRef.current = false;allowOpenRef.current = true;@@ -98,6 +98,12 @@ export const EnhancedTooltip = forwardRef(return;}+ if (eventType === "mouseLeave") {+ allowOpenRef.current = true;+ isFocusedRef.current = true;+ return;+ }+if (isFocusedRef.current === false) {showTooltipDelayed();}@@ -123,6 +129,20 @@ export const EnhancedTooltip = forwardRef(onKeyDown: () => {handleDisableOpen();},+ /*+ When onKeyDown or onPointerDown events occur, the tooltips are disabled.+ Inorder not to show them when the drag operation is under progress.+ However, there is a scenario in which users press keyDown,+ drag the mouse, and leaves the icon and then leaves the drag on the input. (e.g., columnGap and rowGap handlers).+ In this case, it is necessary to reset and enable the tooltips to appear again when+ users hover over the icon after completing the drag operation. Without this reset,+ the tooltips may not appear if the icon is revisited following a keyDown and drag operation.+ Because showTooltipDelayed.cancel() is called in handleDisableOpen, or onKeyDown and onPointerDown events.+ */+ onMouseLeave: (event: React.MouseEvent<HTMLElement>) => {+ handleFocusEventsDebounced("mouseLeave");+ event.preventDefault();+ },};const onOpenChange = (isOpen: boolean) => {