Added option to disable search bar autofocus
This commit is contained in:
parent
0ec77c33bf
commit
df6d96f5b6
8 changed files with 45 additions and 6 deletions
10
DEV_GUIDELINES.md
Normal file
10
DEV_GUIDELINES.md
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
## Adding new config key
|
||||||
|
|
||||||
|
1. Edit utils/init/initialConfig.json
|
||||||
|
2. Edit client/src/interfaces/Config.ts
|
||||||
|
3. Edit client/src/utility/templateObjects/configTemplate.ts
|
||||||
|
|
||||||
|
If config value will be used in a form:
|
||||||
|
|
||||||
|
4. Edit client/src/interfaces/Forms.ts
|
||||||
|
5. Edit client/src/utility/templateObjects/settingsTemplate.ts
|
|
@ -5,7 +5,7 @@ import { connect } from 'react-redux';
|
||||||
import { createNotification } from '../../store/actions';
|
import { createNotification } from '../../store/actions';
|
||||||
|
|
||||||
// Typescript
|
// Typescript
|
||||||
import { NewNotification } from '../../interfaces';
|
import { Config, GlobalState, NewNotification } from '../../interfaces';
|
||||||
|
|
||||||
// CSS
|
// CSS
|
||||||
import classes from './SearchBar.module.css';
|
import classes from './SearchBar.module.css';
|
||||||
|
@ -16,16 +16,20 @@ import { searchParser, urlParser, redirectUrl } from '../../utility';
|
||||||
interface ComponentProps {
|
interface ComponentProps {
|
||||||
createNotification: (notification: NewNotification) => void;
|
createNotification: (notification: NewNotification) => void;
|
||||||
setLocalSearch: (query: string) => void;
|
setLocalSearch: (query: string) => void;
|
||||||
|
config: Config;
|
||||||
|
loading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SearchBar = (props: ComponentProps): JSX.Element => {
|
const SearchBar = (props: ComponentProps): JSX.Element => {
|
||||||
const { setLocalSearch, createNotification } = props;
|
const { setLocalSearch, createNotification, config, loading } = props;
|
||||||
|
|
||||||
const inputRef = useRef<HTMLInputElement>(document.createElement('input'));
|
const inputRef = useRef<HTMLInputElement>(document.createElement('input'));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
inputRef.current.focus();
|
if (!loading && !config.disableAutofocus) {
|
||||||
}, []);
|
inputRef.current.focus();
|
||||||
|
}
|
||||||
|
}, [config]);
|
||||||
|
|
||||||
const clearSearch = () => {
|
const clearSearch = () => {
|
||||||
inputRef.current.value = '';
|
inputRef.current.value = '';
|
||||||
|
@ -78,4 +82,11 @@ const SearchBar = (props: ComponentProps): JSX.Element => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default connect(null, { createNotification })(SearchBar);
|
const mapStateToProps = (state: GlobalState) => {
|
||||||
|
return {
|
||||||
|
config: state.config.config,
|
||||||
|
loading: state.config.loading,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, { createNotification })(SearchBar);
|
||||||
|
|
|
@ -121,6 +121,18 @@ const SearchSettings = (props: Props): JSX.Element => {
|
||||||
<option value={0}>False</option>
|
<option value={0}>False</option>
|
||||||
</select>
|
</select>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor="disableAutofocus">Disable search bar autofocus</label>
|
||||||
|
<select
|
||||||
|
id="disableAutofocus"
|
||||||
|
name="disableAutofocus"
|
||||||
|
value={formData.disableAutofocus ? 1 : 0}
|
||||||
|
onChange={(e) => inputChangeHandler(e, { isBool: true })}
|
||||||
|
>
|
||||||
|
<option value={1}>True</option>
|
||||||
|
<option value={0}>False</option>
|
||||||
|
</select>
|
||||||
|
</InputGroup>
|
||||||
<Button>Save changes</Button>
|
<Button>Save changes</Button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
@ -20,4 +20,5 @@ export interface Config {
|
||||||
kubernetesApps: boolean;
|
kubernetesApps: boolean;
|
||||||
unpinStoppedApps: boolean;
|
unpinStoppedApps: boolean;
|
||||||
useAmericanDate: boolean;
|
useAmericanDate: boolean;
|
||||||
|
disableAutofocus: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ export interface SearchForm {
|
||||||
hideSearch: boolean;
|
hideSearch: boolean;
|
||||||
defaultSearchProvider: string;
|
defaultSearchProvider: string;
|
||||||
searchSameTab: boolean;
|
searchSameTab: boolean;
|
||||||
|
disableAutofocus: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OtherSettingsForm {
|
export interface OtherSettingsForm {
|
||||||
|
|
|
@ -22,4 +22,5 @@ export const configTemplate: Config = {
|
||||||
kubernetesApps: false,
|
kubernetesApps: false,
|
||||||
unpinStoppedApps: false,
|
unpinStoppedApps: false,
|
||||||
useAmericanDate: false,
|
useAmericanDate: false,
|
||||||
|
disableAutofocus: false,
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,4 +28,5 @@ export const searchSettingsTemplate: SearchForm = {
|
||||||
hideSearch: false,
|
hideSearch: false,
|
||||||
searchSameTab: false,
|
searchSameTab: false,
|
||||||
defaultSearchProvider: 'l',
|
defaultSearchProvider: 'l',
|
||||||
|
disableAutofocus: false,
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,5 +18,7 @@
|
||||||
"dockerApps": false,
|
"dockerApps": false,
|
||||||
"dockerHost": "localhost",
|
"dockerHost": "localhost",
|
||||||
"kubernetesApps": false,
|
"kubernetesApps": false,
|
||||||
"unpinStoppedApps": false
|
"unpinStoppedApps": false,
|
||||||
|
"useAmericanDate": false,
|
||||||
|
"disableAutofocus": false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue