From 639f2412d10076f2b17a9cfd8668a4a67a6566fd Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Fri, 24 Sep 2021 12:02:49 +0100 Subject: [PATCH] Fix outline on non-draw-style rectangles --- packages/core/src/hooks/useStyle.tsx | 1 - .../src/shape/shapes/rectangle/rectangle.tsx | 25 ++++++++++++++++++- .../tldraw/src/shape/shapes/text/text.tsx | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/core/src/hooks/useStyle.tsx b/packages/core/src/hooks/useStyle.tsx index 9c6d086a2..0bea1498f 100644 --- a/packages/core/src/hooks/useStyle.tsx +++ b/packages/core/src/hooks/useStyle.tsx @@ -130,7 +130,6 @@ const tlcss = css` } .tl-container * { - user-select: none; box-sizing: border-box; } diff --git a/packages/tldraw/src/shape/shapes/rectangle/rectangle.tsx b/packages/tldraw/src/shape/shapes/rectangle/rectangle.tsx index 846bbcca1..25d23587d 100644 --- a/packages/tldraw/src/shape/shapes/rectangle/rectangle.tsx +++ b/packages/tldraw/src/shape/shapes/rectangle/rectangle.tsx @@ -134,7 +134,30 @@ export const Rectangle = new ShapeUtil + const { + style, + size: [width, height], + } = shape + + const styles = getShapeStyle(style, false) + const strokeWidth = +styles.strokeWidth + + const sw = strokeWidth + + if (style.dash === DashStyle.Draw) { + return + } + + return ( + + ) }, getBounds(shape) { diff --git a/packages/tldraw/src/shape/shapes/text/text.tsx b/packages/tldraw/src/shape/shapes/text/text.tsx index 290c763ac..6abe33a3b 100644 --- a/packages/tldraw/src/shape/shapes/text/text.tsx +++ b/packages/tldraw/src/shape/shapes/text/text.tsx @@ -162,6 +162,7 @@ export const Text = new ShapeUtil(() => ( style={{ font, color: styles.stroke, + userSelect: isEditing ? 'all' : 'none', }} name="text" defaultValue={text}