Skip to content

Commit

Permalink
fix: inaccurate width calculation when margin contains extra spaces (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mengshang918 committed Jul 14, 2022
1 parent c79db5c commit 22f4eeb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const unitedSchema = {
fieldKey: 'margin',
type: 'string',
title: '组件外边距',
transform: ['trim'],
ui: {
type: 'text',
placeholder: '形如0 30px 20px 0 | 0 30px',
Expand All @@ -37,6 +38,7 @@ const unitedSchema = {
fieldKey: 'padding',
type: 'string',
title: '组件内边距',
transform: ['trim'],
ui: {
type: 'text',
placeholder: '形如0 10px 0 10px | 0 10px',
Expand Down
3 changes: 3 additions & 0 deletions packages/generator/src/fields/container/root.field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ const unitedSchema = [
fieldKey: 'margin',
type: 'string',
title: '标题外边距',
transform: ['trim'],
ui: {
type: 'text',
disabled: false,
Expand Down Expand Up @@ -290,6 +291,7 @@ const unitedSchema = [
fieldKey: 'margin',
type: 'string',
title: '组件外边距',
transform: ['trim'],
ui: {
type: 'text',
placeholder: '形如0 30px 20px 0 | 0 30px',
Expand All @@ -299,6 +301,7 @@ const unitedSchema = [
fieldKey: 'padding',
type: 'string',
title: '组件内边距',
transform: ['trim'],
ui: {
type: 'text',
placeholder: '形如0 10px 0 10px | 0 10px',
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CSSProperties } from 'react'
* @Author: jiangxiaowei
* @Date: 2020-05-30 15:05:13
* @Last Modified by: jiangxiaowei
* @Last Modified time: 2022-06-23 17:53:28
* @Last Modified time: 2022-07-14 13:25:05
*/
import type { TreeItems, TreeItem } from '../tree/types'
import type { Map } from './type'
Expand Down Expand Up @@ -408,7 +408,7 @@ export const handleMargin = (style: CSSProperties): void => {
if (width) {
if (margin) {
if (typeof margin === 'string') {
const marginArr = margin.split(' ')
const marginArr = margin.trim().split(' ')
if (marginArr.length === 1) {
marginRight = margin
marginLeft = margin
Expand Down

0 comments on commit 22f4eeb

Please sign in to comment.