1
1
import React , { useEffect , useState } from 'react' ;
2
- import { TextInput } from '@patternfly/react-core' ;
2
+ import { TextArea } from '@patternfly/react-core' ;
3
3
4
4
import { IOptionsAdditionalFields , ITimes , Options , Toolbar , ToolbarItem } from '@kobsio/shared' ;
5
5
import { IOptions } from '../../utils/interfaces' ;
@@ -12,11 +12,12 @@ interface ILogsToolbarProps {
12
12
const LogsToolbar : React . FunctionComponent < ILogsToolbarProps > = ( { options, setOptions } : ILogsToolbarProps ) => {
13
13
const [ query , setQuery ] = useState < string > ( options . query ) ;
14
14
15
- // onEnter is used to detect if the user pressed the "ENTER" key. If this is the case we are calling the setOptions
16
- // function to trigger the search.
17
- // use "SHIFT" + "ENTER".
18
- const onEnter = ( e : React . KeyboardEvent < HTMLInputElement > | undefined ) : void => {
15
+ // onEnter is used to detect if the user pressed the "ENTER" key. If this is the case we will not add a newline.
16
+ // Instead of this we are calling the setOptions function to trigger the search.
17
+ // use "SHIFT" + "ENTER" to write multiple lines .
18
+ const onEnter = ( e : React . KeyboardEvent < HTMLTextAreaElement > | undefined ) : void => {
19
19
if ( e ?. key === 'Enter' && ! e . shiftKey ) {
20
+ e . preventDefault ( ) ;
20
21
setOptions ( { ...options , query : query } ) ;
21
22
}
22
23
} ;
@@ -42,8 +43,10 @@ const LogsToolbar: React.FunctionComponent<ILogsToolbarProps> = ({ options, setO
42
43
return (
43
44
< Toolbar usePageInsets = { true } >
44
45
< ToolbarItem grow = { true } >
45
- < TextInput
46
+ < TextArea
46
47
aria-label = "Query"
48
+ resizeOrientation = "vertical"
49
+ rows = { 1 }
47
50
type = "text"
48
51
value = { query }
49
52
onChange = { ( value : string ) : void => setQuery ( value ) }
0 commit comments