Skip to content

Commit b94cad7

Browse files
committed
fix: restore editor refresh fields
1 parent 017db43 commit b94cad7

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

src/editor-v2/components/DynamicForm/FieldBase/FieldBase.scss

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@ $block: '.#{$ns}field-base';
55

66
#{$block} {
77
$class: &;
8-
padding: 16px 12px;
8+
padding: 16px 12px 16px 0;
99
border-bottom: 1px solid var(--g-color-line-generic);
1010

1111
position: relative;
1212
display: flex;
1313
flex-direction: row;
1414
align-items: flex-start;
15-
gap: 8px;
1615

1716
&:hover {
18-
& > #{$class}__top > #{$class}__button {
17+
& > #{$class}__top #{$class}__title > #{$class}__button {
1918
opacity: 1;
2019
}
2120
}
@@ -28,6 +27,7 @@ $block: '.#{$ns}field-base';
2827
width: 100%;
2928
flex-basis: initial;
3029
}
30+
3131
& > #{$block}__children {
3232
width: 100%;
3333
}
@@ -37,12 +37,13 @@ $block: '.#{$ns}field-base';
3737
display: flex;
3838
align-items: center;
3939
gap: 4px;
40-
flex: 0 0 64px;
41-
word-break: break-all;
40+
flex: 0 0 84px;
41+
word-break: break-word;
4242
}
4343

4444
&__children {
4545
flex: 2 1 auto;
46+
margin-left: 12px;
4647
}
4748

4849
&__foldable {
@@ -68,7 +69,9 @@ $block: '.#{$ns}field-base';
6869

6970
&__title {
7071
@include text-body-2;
71-
margin: 5px 0;
72+
margin: 5px 16px 5px 0;
73+
display: flex;
74+
flex-direction: row;
7275

7376
&_size {
7477
&_s {

src/editor-v2/components/DynamicForm/FieldBase/FieldBase.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {ArrowToggle} from '@gravity-ui/uikit';
1+
import {ArrowToggle, Button, Icon} from '@gravity-ui/uikit';
2+
import {ArrowRotateLeft} from '@gravity-ui/icons';
23
import _ from 'lodash';
34
import * as React from 'react';
45

@@ -25,13 +26,29 @@ const FieldBase: React.FC<FieldBaseProps> = ({
2526
textSize = 's',
2627
children,
2728
expandable = false,
29+
onRefresh,
2830
}) => {
2931
const [showChildren, setShowChildren] = React.useState(!expandable);
3032

3133
const titleComponent = React.useMemo(() => {
3234
if (title) {
3335
const defaultTitle = (
34-
<div className={b('title', {size: textSize})}>{_.capitalize(title)}</div>
36+
<div className={b('title', {size: textSize})}>
37+
{onRefresh && (
38+
<Button
39+
className={b('button')}
40+
onClick={(e: React.MouseEvent<HTMLButtonElement>) => {
41+
e.stopPropagation();
42+
onRefresh(undefined);
43+
}}
44+
view={'flat'}
45+
size={'xs'}
46+
>
47+
<Icon data={ArrowRotateLeft} size={14} />
48+
</Button>
49+
)}
50+
<span>{_.capitalize(title)}</span>
51+
</div>
3552
);
3653

3754
if (expandable) {
@@ -51,7 +68,7 @@ const FieldBase: React.FC<FieldBaseProps> = ({
5168
}
5269

5370
return null;
54-
}, [expandable, showChildren, textSize, title]);
71+
}, [expandable, showChildren, textSize, title, onRefresh]);
5572

5673
return (
5774
<div className={b({expandable}, className)}>

0 commit comments

Comments
 (0)