mirror of
https://github.com/element-plus/element-plus.git
synced 2025-02-17 11:49:41 +08:00
feat(components): [form] scroll-into-view options (#12164)
This commit is contained in:
parent
8144dc7361
commit
eb88722841
@ -126,7 +126,7 @@ form/accessibility
|
||||
### Form Attributes
|
||||
|
||||
| Name | Description | Type | Default |
|
||||
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------- | ------- |
|
||||
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- | ------- |
|
||||
| model | Data of form component. | ^[object]`Record<string, any>` | — |
|
||||
| rules | Validation rules of form. | ^[object]`FormRules` | — |
|
||||
| inline | Whether the form is inline. | ^[boolean] | false |
|
||||
@ -142,6 +142,7 @@ form/accessibility
|
||||
| size | Control the size of components in this form. | ^[enum]`'large' \| 'default' \| 'small'` | — |
|
||||
| disabled | Whether to disable all components in this form. If set to `true`, it will override the `disabled` prop of the inner component. | ^[boolean] | false |
|
||||
| scroll-to-error | When validation fails, scroll to the first error form entry. | ^[boolean] | false |
|
||||
| scroll-into-view-options | When validation fails, it scrolls to the first error item based on the scrollIntoView option. [scrollIntoView](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView). | ^[object] / ^[boolean] | — |
|
||||
|
||||
### Form Methods
|
||||
|
||||
|
@ -104,6 +104,12 @@ export const formProps = buildProps({
|
||||
* @description When validation fails, scroll to the first error form entry.
|
||||
*/
|
||||
scrollToError: Boolean,
|
||||
/**
|
||||
* @description When validation fails, it scrolls to the first error item based on the scrollIntoView option.
|
||||
*/
|
||||
scrollIntoViewOptions: {
|
||||
type: [Object, Boolean],
|
||||
},
|
||||
} as const)
|
||||
export type FormProps = ExtractPropTypes<typeof formProps>
|
||||
export type FormMetaProps = ExtractPropTypes<typeof formMetaProps>
|
||||
|
@ -145,7 +145,7 @@ const validateField: FormContext['validateField'] = async (
|
||||
const scrollToField = (prop: FormItemProp) => {
|
||||
const field = filterFields(fields, prop)[0]
|
||||
if (field) {
|
||||
field.$el?.scrollIntoView()
|
||||
field.$el?.scrollIntoView(props.scrollIntoViewOptions)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user