Skip to content

Commit

Permalink
fix(antd): Prevent native events bubbles
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Apr 9, 2021
1 parent 3ceedb1 commit 11e14a3
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
"version:preminor": "npm run prevesion && lerna version preminor --preid beta --force-publish=* --no-git-tag-version -m \"chore(versions): publish packages %s\"",
"version:major": "npm run prevesion && lerna version major --force-publish=* --no-git-tag-version -m \"chore(versions): publish packages %s\"",
"release:force": "lerna publish from-package --yes",
"prelease:force": "lerna publish from-package --yes --dist-tag next",
"release": "lerna publish",
"prelease": "lerna publish --dist-tag next",
"lint": "eslint --ext .ts,.tsx,.js \"packages/*/src/**.@(ts|tsx|js)\" \"scripts/**/*.js\" --fix",
"postinstall": "opencollective-postinstall"
},
Expand All @@ -52,10 +54,6 @@
"devDependencies": {
"@alifd/next": "^1.19.1",
"@rollup/plugin-commonjs": "^17.0.0",
"less": "^4.1.1",
"less-plugin-npm-import": "^2.1.0",
"rollup-plugin-postcss": "^4.0.0",
"postcss": "^8.0.0",
"@testing-library/jest-dom": "^5.0.0",
"@testing-library/react": "^11.2.3",
"@testing-library/vue": "^5.6.1",
Expand Down Expand Up @@ -120,7 +118,7 @@
"mfetch": "^0.2.27",
"mobx": "^6.0.4",
"mobx-react-lite": "^3.1.6",
"escape-string-regexp":"^4.0.0",
"escape-string-regexp": "^4.0.0",
"onchange": "^5.2.0",
"opencollective": "^1.0.3",
"opencollective-postinstall": "^2.0.2",
Expand Down Expand Up @@ -187,4 +185,4 @@
"dependencies": {
"@ant-design/icons": "^4.0.2"
}
}
}
2 changes: 2 additions & 0 deletions packages/antd/src/array-cards/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const ArrayCards: ComposedArrayCards = observer((props) => {
<ArrayBase.Item key={index} index={index}>
<Card
{...props}
onChange={() => {}}
className={cls(`${prefixCls}-item`, props.className)}
title={title}
extra={extra}
Expand All @@ -124,6 +125,7 @@ export const ArrayCards: ComposedArrayCards = observer((props) => {
return (
<Card
{...props}
onChange={() => {}}
className={cls(`${prefixCls}-item`, props.className)}
title={props.title || field.title}
>
Expand Down
8 changes: 6 additions & 2 deletions packages/antd/src/array-items/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ export const ArrayItems: ComposedArrayItems = observer((props) => {
const schema = useFieldSchema()
const addition = useAddition()
const dataSource = Array.isArray(field.value) ? field.value : []
if(!schema) throw new Error('can not found schema object')
if (!schema) throw new Error('can not found schema object')
return (
<ArrayBase>
<div {...props} className={cls(prefixCls, props.className)}>
<div
{...props}
onChange={() => {}}
className={cls(prefixCls, props.className)}
>
<SortableList
useDragHandle
lockAxis="y"
Expand Down
1 change: 1 addition & 0 deletions packages/antd/src/array-table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ export const ArrayTable: ComposedArrayTable = observer(
size="small"
rowKey={defaultRowKey}
{...props}
onChange={() => {}}
bordered
pagination={false}
columns={columns}
Expand Down
12 changes: 7 additions & 5 deletions packages/core/src/shared/internals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ import { isArrayField, isGeneralField, isQuery, isVoidField } from './externals'
import { ReservedProperties } from './constants'

export const isHTMLInputEvent = (event: any, stopPropagation = true) => {
if (event?.currentTarget) {
if (event?.target) {
if (isValid(event.target.value) || isValid(event.target.checked))
return true
if (
event.currentTarget.tagName &&
event.currentTarget.tagName !== 'INPUT' &&
event.currentTarget.tagName !== 'TEXTAREA' &&
event.currentTarget.tagName !== 'SELECT'
event.target.tagName &&
event.target.tagName !== 'INPUT' &&
event.target.tagName !== 'TEXTAREA' &&
event.target.tagName !== 'SELECT'
) {
return false
}
Expand Down
1 change: 0 additions & 1 deletion scripts/build-style/buildAllStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const generateCssStyleInject = async (cssFilePath: string) => {

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export const buildAllStyles = async (outputFile: string) => {
const outputFilePath = 'dist/formily.css'

await build({
input: 'src/style.ts',
Expand Down

0 comments on commit 11e14a3

Please sign in to comment.