Skip to content

Commit

Permalink
fix(element): remove Space gap when child is hidden and attrs pass ch…
Browse files Browse the repository at this point in the history
…ildren (#3526)
  • Loading branch information
frehaiku authored Nov 7, 2022
1 parent 5ab10b4 commit 8bcd51f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
27 changes: 14 additions & 13 deletions packages/element/src/space/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const spaceSize = {
export const Space = defineComponent<SpaceProps>({
name: 'FSpace',
props: ['size', 'direction', 'align'],
setup(props, { slots }) {
setup(props, { attrs, slots }) {
const layout = useFormLayout()

return () => {
Expand Down Expand Up @@ -72,23 +72,24 @@ export const Space = defineComponent<SpaceProps>({
{
class: itemClassName,
key: `${itemClassName}-${i}`,
style:
i === len - 1
? {}
: {
[direction === 'vertical'
? 'marginBottom'
: marginDirection]:
typeof size === 'string'
? `${spaceSize[size]}px`
: `${size}px`,
},
},
{ default: () => [child] }
)
)

return h('div', { class: someSpaceClass }, { default: () => renderItems })
return h(
'div',
{
...attrs,
class: { ...(attrs as any).class, ...someSpaceClass },
style: {
...(attrs as any).style,
gap:
typeof size === 'string' ? `${spaceSize[size]}px` : `${size}px`,
},
},
{ default: () => renderItems }
)
}
},
})
Expand Down
4 changes: 4 additions & 0 deletions packages/element/src/space/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@
align-items: baseline;
}
}

&-item {
display: contents;
}
}

0 comments on commit 8bcd51f

Please sign in to comment.