MCPcopy
hub / github.com/react-component/form / validateFieldsAndScroll

Function validateFieldsAndScroll

src/createDOMForm.js:61–99  ·  view source on GitHub ↗
(ns, opt, cb)

Source from the content-addressed store, hash-verified

59 },
60
61 validateFieldsAndScroll(ns, opt, cb) {
62 const { names, callback, options } = getParams(ns, opt, cb);
63
64 const newCb = (error, values) => {
65 if (error) {
66 const validNames = this.fieldsStore.getValidFieldsName();
67 let firstNode;
68 let firstTop;
69
70 validNames.forEach((name) => {
71 if (has(error, name)) {
72 const instance = this.getFieldInstance(name);
73 if (instance) {
74 const node = ReactDOM.findDOMNode(instance);
75 const top = node.getBoundingClientRect().top;
76 if (node.type !== 'hidden' && (firstTop === undefined || firstTop > top)) {
77 firstTop = top;
78 firstNode = node;
79 }
80 }
81 }
82 });
83
84 if (firstNode) {
85 const c = options.container || getScrollableContainer(firstNode);
86 scrollIntoView(firstNode, c, {
87 onlyScrollIfNeeded: true,
88 ...options.scroll,
89 });
90 }
91 }
92
93 if (typeof callback === 'function') {
94 callback(error, values);
95 }
96 };
97
98 return this.validateFields(names, options, newCb);
99 },
100};
101
102function createDOMForm(option) {

Callers

nothing calls this directly

Calls 1

getParamsFunction · 0.90

Tested by

no test coverage detected