Skip to content

Commit

Permalink
fix(dimensions): don't apply style key if == null
Browse files Browse the repository at this point in the history
  • Loading branch information
johnleider committed May 21, 2024
1 parent 31c43cf commit 43683ca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
5 changes: 1 addition & 4 deletions packages/vuetify/src/components/VOverlay/VOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ export const VOverlay = genericComponent<OverlaySlots>()({
scrimEvents,
} = useActivator(props, { isActive, isTop: localTop })
const { dimensionStyles } = useDimension(props)
const definedDimensionStyles = computed(() => {
return Object.fromEntries(Object.entries(dimensionStyles.value).filter(([_, v]) => v != null))
})
const isMounted = useHydration()
const { scopeId } = useScopeId()

Expand Down Expand Up @@ -330,8 +327,8 @@ export const VOverlay = genericComponent<OverlaySlots>()({
props.contentClass,
]}
style={[
dimensionStyles.value,
contentStyles.value,
definedDimensionStyles.value,
]}
{ ...contentEvents.value }
{ ...props.contentProps }
Expand Down
27 changes: 19 additions & 8 deletions packages/vuetify/src/composables/dimensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,25 @@ export const makeDimensionProps = propsFactory({
}, 'dimension')

export function useDimension (props: DimensionProps) {
const dimensionStyles = computed(() => ({
height: convertToUnit(props.height),
maxHeight: convertToUnit(props.maxHeight),
maxWidth: convertToUnit(props.maxWidth),
minHeight: convertToUnit(props.minHeight),
minWidth: convertToUnit(props.minWidth),
width: convertToUnit(props.width),
}))
const dimensionStyles = computed(() => {
const styles: Record<string, any> = {}

const height = convertToUnit(props.height)
const maxHeight = convertToUnit(props.maxHeight)
const maxWidth = convertToUnit(props.maxWidth)
const minHeight = convertToUnit(props.minHeight)
const minWidth = convertToUnit(props.minWidth)
const width = convertToUnit(props.width)

if (height != null) styles.height = height
if (maxHeight != null) styles.maxHeight = maxHeight
if (maxWidth != null) styles.maxWidth = maxWidth
if (minHeight != null) styles.minHeight = minHeight
if (minWidth != null) styles.minWidth = minWidth
if (width != null) styles.width = width

return styles
})

return { dimensionStyles }
}

0 comments on commit 43683ca

Please sign in to comment.