mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 21:16:00 +00:00
seach improvement
This commit is contained in:
26
packages/web/src/widgets/SearchInput.js
Normal file
26
packages/web/src/widgets/SearchInput.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import keycodes from '../utility/keycodes';
|
||||
|
||||
const StyledInput = styled.input`
|
||||
flex: 1;
|
||||
min-width: 90px;
|
||||
`;
|
||||
|
||||
export default function SearchInput({ placeholder, filter, setFilter }) {
|
||||
const handleKeyDown = (ev) => {
|
||||
if (ev.keyCode == keycodes.escape) {
|
||||
setFilter('');
|
||||
}
|
||||
};
|
||||
return (
|
||||
<StyledInput
|
||||
type="text"
|
||||
placeholder={placeholder}
|
||||
value={filter}
|
||||
onChange={(e) => setFilter(e.target.value)}
|
||||
onFocus={(e) => e.target.select()}
|
||||
onKeyDown={handleKeyDown}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user