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 = {
6262 const nonNativeEvents = {
6363 input : ( value , $e ) => {
6464 const emitChange = listeners . change
65+
6566 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 ) )
6771 }
6872 }
6973 }
7074 const { nonNative } = extractListeners ( { listeners } , nonNativeEvents )
7175
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
8290 } ,
83- on : nonNative
84- } , slots ( ) . default )
91+ slots ( ) . default
92+ )
8593 }
8694}
8795
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ storiesOf('UI | Textarea', module)
1414 mt="2"
1515 placeholder="Here is a sample placeholder"
1616 size="md"
17+ @change="handleChange"
1718 :value="textareaContent"
1819 />
1920 </CBox>
@@ -27,3 +28,31 @@ storiesOf('UI | Textarea', module)
2728 action : action ( )
2829 }
2930 } ) )
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