File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed
Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ <h2>Active chat</h2>
2727 < p class ="you "> Bob: Cool, where can I learn more?</ p >
2828 </ div >
2929 < form >
30- < input type ="text " aria-label ="Enter your chat message here " required autofocus >
30+ < input type ="text " aria-label ="Enter your chat message here " autofocus >
3131 < button > Send</ button >
3232 </ form >
3333 </ section >
Original file line number Diff line number Diff line change @@ -22,13 +22,15 @@ messages.scrollTop = messages.scrollHeight;
2222form . addEventListener ( 'submit' , e => {
2323 e . preventDefault ( ) ;
2424
25- let pElem = document . createElement ( 'p' ) ;
26- pElem . setAttribute ( 'class' , 'me' ) ;
27- pElem . textContent = 'Chris: ' + input . value ;
25+ if ( input . value !== '' ) {
26+ let pElem = document . createElement ( 'p' ) ;
27+ pElem . setAttribute ( 'class' , 'me' ) ;
28+ pElem . textContent = 'Chris: ' + input . value ;
2829
29- messages . appendChild ( pElem ) ;
30- messages . scrollTop = messages . scrollHeight ;
30+ messages . appendChild ( pElem ) ;
31+ messages . scrollTop = messages . scrollHeight ;
3132
32- input . value = '' ;
33- input . focus ( ) ;
33+ input . value = '' ;
34+ input . focus ( ) ;
35+ }
3436} ) ;
You can’t perform that action at this time.
0 commit comments