Skip to content

Commit 6b7d4b7

Browse files
committed
fix(ui-text-input,ui-flex): fix focus ring causing scrollbars to appear
The cause was that we were using CSS borders whole scale changes, this causes the component's size to change if there is no padding INSTUI-4523
1 parent 79100e0 commit 6b7d4b7

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

packages/ui-flex/src/Flex/README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -279,25 +279,28 @@ type: example
279279
### Handling overflow
280280

281281
When `direction` is set to `column`, Flex.Items' `overflowY` property is automagically set
282-
to `auto` to account for content overflow with a vertical scrollbar.
282+
to `auto` to account for content overflow with a vertical scrollbar. Add padding, so focus rings are not cut off.
283283

284284
> To override this default, simply set `overflowY` on the Flex.Item to either `visible` or `hidden`.
285285
286286
```js
287287
---
288288
type: example
289289
---
290-
<Flex
291-
withVisualDebug
292-
direction="column"
293-
>
294-
<Flex.Item padding="small">
295-
<Heading>Pandas are cute, right?</Heading>
296-
</Flex.Item>
297-
<Flex.Item size="150px" padding="small">
298-
<Img src={avatarSquare} />
299-
</Flex.Item>
300-
</Flex>
290+
<Flex
291+
withVisualDebug
292+
direction="column"
293+
>
294+
<Flex.Item padding="small">
295+
<Heading>Pandas are cute, right?</Heading>
296+
</Flex.Item>
297+
<Flex.Item>
298+
<TextInput name="name" renderLabel="If you dont add padding, the focus ring will be cut off!" />
299+
</Flex.Item>
300+
<Flex.Item size="150px" padding="small">
301+
<Img src={avatarSquare} />
302+
</Flex.Item>
303+
</Flex>
301304
```
302305
303306
### A few common layouts

packages/ui-text-input/src/TextInput/styles.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ const generateStyle = (
8181
const focusedStyle = focused
8282
? {
8383
opacity: 1,
84-
transform: 'scale(1)'
84+
outlineOffset: '0.15rem'
8585
}
8686
: {
8787
opacity: 0,
88-
transform: 'scale(0.95)'
88+
outlineOffset: '-0.9rem'
8989
}
9090

9191
const invalidStyle = invalid
@@ -176,13 +176,13 @@ const generateStyle = (
176176
position: 'absolute',
177177
display: 'block',
178178
boxSizing: 'border-box',
179-
top: '-0.25rem',
180-
bottom: '-0.25rem',
181-
left: '-0.25rem',
182-
right: '-0.25rem',
183-
border: `${componentTheme.focusOutlineWidth} ${componentTheme.focusOutlineStyle} ${componentTheme.focusOutlineColor}`,
184-
borderRadius: `calc(${componentTheme.borderRadius} * 1.5)`,
185-
transition: 'all 0.2s',
179+
top: '0',
180+
bottom: '0',
181+
left: '0',
182+
right: '0',
183+
outline: `${componentTheme.focusOutlineWidth} ${componentTheme.focusOutlineStyle} ${componentTheme.focusOutlineColor}`,
184+
borderRadius: componentTheme.borderRadius,
185+
transition: 'opacity 0.2s, outline-offset 0.2s ease-out',
186186

187187
...focusedStyle, // properties to transition on :focus
188188
...invalidAndFocusedStyle

0 commit comments

Comments
 (0)