This repository was archived by the owner on Sep 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +58
-13
lines changed
packages/chakra-ui-core/src/CTextarea Expand file tree Collapse file tree 3 files changed +58
-13
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @chakra-ui/vue ' : patch
3
+ ' @chakra-ui/nuxt ' : patch
4
+ ' @chakra-ui/theme-vue ' : patch
5
+ ' chakra-ui-docs ' : patch
6
+ ---
7
+
8
+ Fixes change event lsitener
Original file line number Diff line number Diff line change @@ -62,26 +62,34 @@ const CTextarea = {
62
62
const nonNativeEvents = {
63
63
input : ( value , $e ) => {
64
64
const emitChange = listeners . change
65
+
65
66
if ( emitChange && $e instanceof Event ) {
66
- emitChange ( value , $e )
67
+ if ( typeof emitChange === 'function' ) {
68
+ return emitChange ( value , $e )
69
+ }
70
+ emitChange . forEach ( listener => listener ( value , $e ) )
67
71
}
68
72
}
69
73
}
70
74
const { nonNative } = extractListeners ( { listeners } , nonNativeEvents )
71
75
72
- return h ( CInput , {
73
- ...rest ,
74
- props : {
75
- ...forwardProps ( props ) ,
76
- as : 'textarea'
77
- } ,
78
- attrs : {
79
- ...defaultStyles ,
80
- ...( data . attrs || { } ) ,
81
- 'data-chakra-component' : 'CTextarea'
76
+ return h (
77
+ CInput ,
78
+ {
79
+ ...rest ,
80
+ props : {
81
+ ...forwardProps ( props ) ,
82
+ as : 'textarea'
83
+ } ,
84
+ attrs : {
85
+ ...defaultStyles ,
86
+ ...( data . attrs || { } ) ,
87
+ 'data-chakra-component' : 'CTextarea'
88
+ } ,
89
+ on : nonNative
82
90
} ,
83
- on : nonNative
84
- } , slots ( ) . default )
91
+ slots ( ) . default
92
+ )
85
93
}
86
94
}
87
95
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ storiesOf('UI | Textarea', module)
14
14
mt="2"
15
15
placeholder="Here is a sample placeholder"
16
16
size="md"
17
+ @change="handleChange"
17
18
:value="textareaContent"
18
19
/>
19
20
</CBox>
@@ -27,3 +28,31 @@ storiesOf('UI | Textarea', module)
27
28
action : action ( )
28
29
}
29
30
} ) )
31
+ . add ( 'Basic Usage with Event' , ( ) => ( {
32
+ components : { CBox, CTextarea } ,
33
+ template : `
34
+ <CBox w="300px">
35
+ <CTextarea
36
+ v-model="textareaContent"
37
+ maxWidth="sm"
38
+ mx="auto"
39
+ mt="2"
40
+ placeholder="Here is a sample placeholder"
41
+ size="md"
42
+ :value="textareaContent"
43
+ @change="handleChange"
44
+ />
45
+ </CBox>
46
+ ` ,
47
+ data ( ) {
48
+ return {
49
+ textareaContent : 'Jonathan Bakebwa is awesome'
50
+ }
51
+ } ,
52
+ methods : {
53
+ action : action ( ) ,
54
+ handleChange ( e ) {
55
+ this . textareaContent = 'You are beautiful :)'
56
+ }
57
+ }
58
+ } ) )
You can’t perform that action at this time.
0 commit comments