File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed
packages/feedback/src/widget Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -88,21 +88,21 @@ export function createWidget({
8888 return ;
8989 }
9090
91- // Simple validation for now, just check for non-empty message
92- if ( ! feedback . message ) {
93- dialog . showError ( 'Please enter in some feedback before submitting!' ) ;
94- return ;
95- }
96-
97- // Simple validation for now, just check for non-empty message if name required
91+ // Simple validation for now, just check for non-empty required fields
92+ const emptyField = [ ] ;
9893 if ( options . isNameRequired && ! feedback . name ) {
99- dialog . showError ( 'Please enter in a name before submitting!' ) ;
94+ emptyField . push ( options . nameLabel ) ;
10095 return ;
10196 }
102-
103- // Simple validation for now, just check for non-empty message if email required
10497 if ( options . isEmailRequired && ! feedback . email ) {
105- dialog . showError ( 'Please enter in an email before submitting!' ) ;
98+ emptyField . push ( options . emailLabel ) ;
99+ return ;
100+ }
101+ if ( ! feedback . message ) {
102+ emptyField . push ( options . messageLabel ) ;
103+ }
104+ if ( ! emptyField . length ) {
105+ dialog . showError ( `Please enter in the following required fields: ${ emptyField . join ( ', ' ) } ` ) ;
106106 return ;
107107 }
108108
You can’t perform that action at this time.
0 commit comments