Skip to content

Commit 00b17cd

Browse files
committed
[2.4.1] Fixed passing touched state from vue-form to control
1 parent c45ee1b commit 00b17cd

File tree

8 files changed

+32
-79
lines changed

8 files changed

+32
-79
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 2.4.1
2+
3+
### Fixed
4+
5+
- Internal `manageTouchedFieldsState` method
6+
- Passing touched state from vue-form to control
7+
18
## 2.4.0
29

310
### Updated

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ See demo at [https://detools.github.io/vue-form](https://detools.github.io/vue-f
7878

7979
## Changelog
8080

81+
- [2.4.1](/CHANGELOG.md#241)
8182
- [2.4.0](/CHANGELOG.md#240)
8283
- [2.3.1](/CHANGELOG.md#231)
8384
- [2.3.0](/CHANGELOG.md#230)

VueForm/ConnectedFormItem.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,3 @@ export default {
1515
)
1616
},
1717
}
18-
19-
/*
20-
<style lang="less">
21-
.is-vue-form-warn .el-form-item__error {
22-
color: #FF9800;
23-
}
24-
25-
.is-vue-form-warn .el-form-item.is-error .el-input__inner,
26-
.is-vue-form-warn .el-form-item.is-error .el-input__inner:focus,
27-
.is-vue-form-warn .el-form-item.is-error .el-textarea__inner,
28-
.is-vue-form-warn .el-form-item.is-error .el-textarea__inner:focus,
29-
.is-vue-form-warn .el-message-box__input input.invalid,
30-
.is-vue-form-warn .el-message-box__input input.invalid:focus {
31-
border-color: #FF9800;
32-
}
33-
</style>
34-
*/

VueForm/Form.js

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -210,19 +210,21 @@ export default {
210210
vm.$set(this.touchedFields, name, true)
211211
}
212212

213-
const isFieldTouched = this.touchedFields[name]
214-
215213
return {
216214
cleanFormValue,
217215
setError,
218216
setAsyncError,
219217
setTouched,
220-
useState: () => [
221-
this.state[name],
222-
setValue,
223-
isFieldTouched && (this.syncErrors[name] || this.asyncErrors[name]),
224-
isFieldTouched,
225-
],
218+
useState: () => {
219+
const isFieldTouched = this.touchedFields[name]
220+
221+
return [
222+
this.state[name],
223+
setValue,
224+
isFieldTouched && (this.syncErrors[name] || this.asyncErrors[name]),
225+
isFieldTouched,
226+
]
227+
},
226228
}
227229
},
228230

@@ -245,7 +247,7 @@ export default {
245247
},
246248

247249
manageTouchedFieldsState() {
248-
this.formFields.forEach(name => this.$set(this.touchedFields, name, true))
250+
this.touchedFields = this.formFields.reduce((memo, name) => ({ ...memo, [name]: true }), {})
249251
},
250252

251253
handleFormDisabled(errors) {
@@ -277,9 +279,6 @@ export default {
277279
this.syncErrors = {}
278280
}
279281

280-
// If Invalid
281-
// There is no SAVE BUTTON
282-
// There is a handleDisabled handler
283282
if (!this.isValid && isSubmitButtonClick) {
284283
return this.handleFormDisabled()
285284
}
@@ -375,18 +374,9 @@ export default {
375374
},
376375

377376
render() {
378-
const className = [
379-
this.class,
380-
{
381-
'is-vue-form-error': !this.isValid && !this.save,
382-
'is-vue-form-warn': !this.isValid && this.save,
383-
},
384-
]
385-
386377
return (
387378
<Form
388379
novalidate
389-
class={className}
390380
label-width={this.labelWidth}
391381
label-suffix={this.labelSuffix}
392382
label-position={this.labelPosition}

docs/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/main.css

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11

2-
.root-container[data-v-6dc3c25e] {
2+
.root-container[data-v-a969b32e] {
33
min-height: 100%;
44
}
5-
.title[data-v-6dc3c25e] {
5+
.title[data-v-a969b32e] {
66
font-size: 40px;
77
margin: 10px 0 0;
88
font-weight: bold;
99
}
10-
.main-container[data-v-6dc3c25e] {
10+
.main-container[data-v-a969b32e] {
1111
display: flex;
1212
flex-direction: row;
1313
justify-content: space-between;
1414
align-items: stretch;
1515
}
16-
.aside[data-v-6dc3c25e] {
16+
.aside[data-v-a969b32e] {
1717
border-top: 1px solid rgba(0, 0, 0, 0.1);
1818
}
19-
.main[data-v-6dc3c25e] {
19+
.main[data-v-a969b32e] {
2020
padding: 10px 40px 40px;
2121
border-top: 1px solid rgba(0, 0, 0, 0.1);
2222
border-left: 1px solid rgba(0, 0, 0, 0.1);
2323
}
24-
.link[data-v-6dc3c25e] {
24+
.link[data-v-a969b32e] {
2525
display: block;
2626
line-height: 40px;
2727
padding-left: 30px;
2828
position: relative;
2929
color: #0a0a0a;
3030
}
31-
.link_active[data-v-6dc3c25e]:before {
31+
.link_active[data-v-a969b32e]:before {
3232
content: '\261B';
3333
position: absolute;
3434
display: block;
@@ -40,31 +40,3 @@
4040
font-size: 20px;
4141
}
4242

43-
44-
.is-vue-form-warn .el-form-item__error {
45-
color: #FF9800;
46-
}
47-
.is-vue-form-warn .el-form-item.is-error .el-input__inner,
48-
.is-vue-form-warn .el-form-item.is-error .el-input__inner:focus,
49-
.is-vue-form-warn .el-form-item.is-error .el-textarea__inner,
50-
.is-vue-form-warn .el-form-item.is-error .el-textarea__inner:focus,
51-
.is-vue-form-warn .el-message-box__input input.invalid,
52-
.is-vue-form-warn .el-message-box__input input.invalid:focus {
53-
border-color: #FF9800;
54-
}
55-
56-
57-
.buttons[data-v-01bb0c7a] {
58-
display: flex;
59-
flex-direction: row;
60-
flex-wrap: no-wrap;
61-
justify-content: flex-start;
62-
align-items: flex-start;
63-
}
64-
.buttons_center[data-v-01bb0c7a] {
65-
justify-content: center;
66-
}
67-
.buttons_end[data-v-01bb0c7a] {
68-
justify-content: flex-end;
69-
}
70-

docs/vendors~main.bundle.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@detools/vue-form",
3-
"version": "2.4.0",
3+
"version": "2.4.1",
44
"description": "Form State Management for VueJS",
55
"main": "VueForm/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)