@@ -156,7 +156,8 @@ export class PfTextInput extends LitElement {
156156 /** Trim text on left */
157157 @property ( { type : Boolean , reflect : true , attribute : 'left-truncated' } ) leftTruncated = false ;
158158
159- /** Value to indicate if the input is modified to show that validation state.
159+ /**
160+ * Value to indicate if the input is modified to show that validation state.
160161 * If set to success, input will be modified to indicate valid state.
161162 * If set to warning, input will be modified to indicate warning state.
162163 * Invalid inputs will display an error state
@@ -233,8 +234,9 @@ export class PfTextInput extends LitElement {
233234 < input id ="input "
234235 .placeholder ="${ this . placeholder ?? '' } "
235236 .value ="${ this . value } "
236- . pattern ="${ this . pattern as string } "
237+ pattern ="${ ifDefined ( this . pattern ) } "
237238 @input ="${ this . #onInput} "
239+ @keydown ="${ this . #onKeydown} "
238240 @blur ="${ this . #onBlur} "
239241 ?disabled ="${ this . matches ( ':disabled' ) || this . disabled } "
240242 ?readonly ="${ this . readonly } "
@@ -260,6 +262,15 @@ export class PfTextInput extends LitElement {
260262 this . #touched = true ;
261263 }
262264
265+ #onKeydown( event : Event ) {
266+ switch ( ( event as KeyboardEvent ) . key ) {
267+ case 'Enter' :
268+ if ( this . reportValidity ( ) ) {
269+ this . #internals. form ?. requestSubmit ( null ) ;
270+ }
271+ }
272+ }
273+
263274 #onBlur( ) {
264275 if ( this . validateOn === 'blur' ) {
265276 this . checkValidity ( ) ;
0 commit comments