Skip to content

Commit df75003

Browse files
committed
Prevent text selection when resizing or dragging
1 parent 76852cd commit df75003

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

apps/webapp/app/components/metrics/QueryWidget.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
import { LoadingBarDivider } from "../primitives/LoadingBarDivider";
1919
import { Callout } from "../primitives/Callout";
2020
import { ChartBarIcon } from "@heroicons/react/24/solid";
21-
import { cn } from "~/utils/cn";
2221
import {
2322
Popover,
2423
PopoverContent,
@@ -171,7 +170,7 @@ export function QueryWidget({
171170

172171
return (
173172
<div className="h-full">
174-
<Card className={cn("h-full overflow-hidden px-0 pb-0", isResizing && "select-none")}>
173+
<Card className="h-full overflow-hidden px-0 pb-0">
175174
<Card.Header draggable={isDraggable}>
176175
<div className="flex items-center gap-1.5">{title}</div>
177176
<Card.Accessory>

apps/webapp/app/components/metrics/TitleWidget.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ export function TitleWidget({
4242
<div
4343
className={cn(
4444
"group flex h-full items-center gap-2 rounded-lg border border-grid-bright bg-background-bright px-4",
45-
isDraggable && "drag-handle cursor-grab active:cursor-grabbing",
46-
isResizing && "select-none"
45+
isDraggable && "drag-handle cursor-grab active:cursor-grabbing"
4746
)}
4847
>
4948
<span className="min-w-0 flex-1 truncate text-lg font-medium text-text-bright">

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.metrics.$dashboardKey/route.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { PageBody, PageContainer } from "~/components/layout/AppLayout";
1616
import { NavBar, PageTitle } from "~/components/primitives/PageHeader";
1717
import { z } from "zod";
1818
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
19+
import { cn } from "~/utils/cn";
1920
import ReactGridLayout from "react-grid-layout";
2021
import { MetricWidget } from "../resources.metric";
2122
import { TitleWidget } from "~/components/metrics/TitleWidget";
@@ -131,6 +132,8 @@ export function MetricDashboard({
131132
const { value, values } = useSearchParams();
132133
const { width, containerRef, mounted } = useContainerWidth();
133134
const [resizingItemId, setResizingItemId] = useState<string | null>(null);
135+
const [isDragging, setIsDragging] = useState(false);
136+
const isInteracting = resizingItemId !== null || isDragging;
134137

135138
const organization = useOrganization();
136139
const project = useProject();
@@ -183,7 +186,10 @@ export function MetricDashboard({
183186
</div>
184187
<div
185188
ref={containerRef}
186-
className="overflow-y-auto scrollbar-thin scrollbar-track-charcoal-800 scrollbar-thumb-charcoal-700"
189+
className={cn(
190+
"overflow-y-auto scrollbar-thin scrollbar-track-charcoal-800 scrollbar-thumb-charcoal-700",
191+
isInteracting && "select-none"
192+
)}
187193
>
188194
{mounted && (
189195
<ReactGridLayout
@@ -198,6 +204,8 @@ export function MetricDashboard({
198204
onLayoutChange={handleLayoutChange}
199205
onResizeStart={(_layout, oldItem) => setResizingItemId(oldItem?.i ?? null)}
200206
onResizeStop={() => setResizingItemId(null)}
207+
onDragStart={() => setIsDragging(true)}
208+
onDragStop={() => setIsDragging(false)}
201209
>
202210
{Object.entries(widgets).map(([key, widget]) => (
203211
<div key={key}>

0 commit comments

Comments
 (0)