Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1b29e77

Browse files
committed
fix: content layout shift on editing due to comma on multiline property name+value
1 parent9f2dcc0 commit1b29e77

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

‎src/editable-value.tsx

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import{Editable,useEditableContext}from"@ark-ui/react";
1+
import{Tooltip}from"#components/tooltip";
2+
import{css,cx}from"#styled-system/css";
3+
import{styled}from"#styled-system/jsx";
4+
import{Editable,Portal,useEditableContext}from"@ark-ui/react";
25
import{useSelector}from"@xstate/store/react";
36
import{TrashIcon,Undo2}from"lucide-react";
47
import{useRef,useState}from"react";
5-
import{css}from"#styled-system/css";
6-
import{styled}from"#styled-system/jsx";
7-
import{Tooltip}from"#components/tooltip";
8+
import{useDevtoolsContext}from"./devtools-context";
89
import{HighlightMatch}from"./highlight-match";
910
import{hypenateProperty}from"./lib/hyphenate-proprety";
1011
import{symbols}from"./lib/symbols";
1112
import{store}from"./store";
12-
import{useDevtoolsContext}from"./devtools-context";
1313

1414
exportinterfaceEditableValueProps{
1515
index:number;
@@ -109,9 +109,19 @@ export const EditableValue = (props: EditableValueProps) => {
109109
}
110110
};
111111

112+
constparentRef=useRef<HTMLDivElement>(null);
113+
112114
return(
113115
<Editable.Root
114-
className={css({display:"flex",alignItems:"center"})}
116+
ref={parentRef}
117+
className={cx(
118+
"group",
119+
css({
120+
display:"flex",
121+
justifyContent:"flex-start",
122+
alignItems:"center",
123+
}),
124+
)}
115125
key={key}
116126
autoResize
117127
selectOnFocus
@@ -122,7 +132,7 @@ export const EditableValue = (props: EditableValueProps) => {
122132
overrideValue(update.value);
123133
}}
124134
>
125-
<Editable.Arearef={ref}>
135+
<Editable.Arearef={ref}className={css({display:"flex"})}>
126136
<Editable.Input
127137
className={css({
128138
margin:"0 -2px -1px!",
@@ -141,7 +151,7 @@ export const EditableValue = (props: EditableValueProps) => {
141151
onBlur={()=>setKey((key)=>key+1)}
142152
aria-label="Property value"
143153
/>
144-
<EditablePreview/>
154+
<EditablePreviewparentRef={parentRef}/>
145155
</Editable.Area>
146156
{isRemovable&&(
147157
<Tooltip
@@ -188,12 +198,15 @@ export const EditableValue = (props: EditableValueProps) => {
188198
/>
189199
</Tooltip>
190200
)}
191-
<span>;</span>
192201
</Editable.Root>
193202
);
194203
};
195204

196-
constEditablePreview=()=>{
205+
constEditablePreview=({
206+
parentRef,
207+
}:{
208+
parentRef:React.RefObject<HTMLSpanElement>;
209+
})=>{
197210
constctx=useEditableContext();
198211
constfilter=useSelector(store,(s)=>s.context.filter);
199212

@@ -202,6 +215,12 @@ const EditablePreview = () => {
202215
<HighlightMatchhighlight={filter}>
203216
{ctx.previewProps.children}
204217
</HighlightMatch>
218+
<Portalcontainer={parentRef}>
219+
<spanclassName={css({display:ctx.isEditing ?"contents" :"none"})}>
220+
;
221+
</span>
222+
</Portal>
223+
{ctx.isEditing ?null :<span>;</span>}
205224
</span>
206225
);
207226
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp