Fix not filling cell (#4099)
* fix(editable): make autoExpand stretch to parent width * fix(editable): adjust snapshot against the new editable * fill URLProperty to parent width Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
parent
d39abc305d
commit
e83b05b661
5 changed files with 8 additions and 16 deletions
|
@ -6,7 +6,7 @@ exports[`components/propertyValueElement Generic fields should allow cancel 1`]
|
|||
class="Editable octo-propertyvalue"
|
||||
placeholder="Empty"
|
||||
spellcheck="true"
|
||||
style="width: 5px;"
|
||||
style="width: 100%;"
|
||||
title=""
|
||||
value=""
|
||||
/>
|
||||
|
@ -94,7 +94,7 @@ exports[`components/propertyValueElement should match snapshot, person, array va
|
|||
class="Editable octo-propertyvalue"
|
||||
placeholder="Empty"
|
||||
spellcheck="true"
|
||||
style="width: 5px;"
|
||||
style="width: 100%;"
|
||||
title=""
|
||||
value=""
|
||||
/>
|
||||
|
|
|
@ -66,7 +66,7 @@ exports[`components/cardDetail/CardDetailProperties cancel on delete dialog shou
|
|||
<input
|
||||
class="Editable octo-propertyvalue"
|
||||
placeholder="Empty"
|
||||
style="width: 5px;"
|
||||
style="width: 100%;"
|
||||
title="1234"
|
||||
value="1234"
|
||||
/>
|
||||
|
@ -159,7 +159,7 @@ exports[`components/cardDetail/CardDetailProperties should match snapshot 1`] =
|
|||
<input
|
||||
class="Editable octo-propertyvalue"
|
||||
placeholder="Empty"
|
||||
style="width: 5px;"
|
||||
style="width: 100%;"
|
||||
title="1234"
|
||||
value="1234"
|
||||
/>
|
||||
|
@ -252,7 +252,7 @@ exports[`components/cardDetail/CardDetailProperties should show property types m
|
|||
<input
|
||||
class="Editable octo-propertyvalue"
|
||||
placeholder="Empty"
|
||||
style="width: 5px;"
|
||||
style="width: 100%;"
|
||||
title="1234"
|
||||
value="1234"
|
||||
/>
|
||||
|
|
|
@ -8,7 +8,7 @@ exports[`properties/link should match snapshot for link with empty url 1`] = `
|
|||
<input
|
||||
class="Editable octo-propertyvalue"
|
||||
placeholder=""
|
||||
style="width: 5px;"
|
||||
style="width: 100%;"
|
||||
title=""
|
||||
value=""
|
||||
/>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
display: flex;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
|
||||
.link {
|
||||
flex: 1 1 auto;
|
||||
|
|
|
@ -116,13 +116,6 @@ export function useEditable(
|
|||
}
|
||||
}
|
||||
|
||||
function borderWidth(style: CSSStyleDeclaration): number {
|
||||
return (
|
||||
parseInt(style.borderLeftWidth || '0', 10) +
|
||||
parseInt(style.borderRightWidth || '0', 10)
|
||||
)
|
||||
}
|
||||
|
||||
const Editable = (props: EditableProps, ref: React.Ref<Focusable>): JSX.Element => {
|
||||
const elementRef = useRef<HTMLInputElement>(null)
|
||||
const elementProps = useEditable(props, ref, elementRef)
|
||||
|
@ -130,9 +123,7 @@ const Editable = (props: EditableProps, ref: React.Ref<Focusable>): JSX.Element
|
|||
useLayoutEffect(() => {
|
||||
if (props.autoExpand && elementRef.current) {
|
||||
const input = elementRef.current
|
||||
const computed = getComputedStyle(input)
|
||||
input.style.width = 'auto'
|
||||
input.style.width = `${input.scrollWidth + borderWidth(computed) + 1}px`
|
||||
input.style.width = '100%'
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue