mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure that cursor should be focused on the first options of the Utility dialogs. Fixes #7110
This commit is contained in:
parent
4d727015fd
commit
b4b658c59d
@ -25,6 +25,7 @@ Bug fixes
|
|||||||
| `Issue #7086 <https://redmine.postgresql.org/issues/7086>`_ - Correct documentation for 'Add named restore point'.
|
| `Issue #7086 <https://redmine.postgresql.org/issues/7086>`_ - Correct documentation for 'Add named restore point'.
|
||||||
| `Issue #7100 <https://redmine.postgresql.org/issues/7100>`_ - Fixed an issue where the Browser tree gets disappears when scrolling sequences.
|
| `Issue #7100 <https://redmine.postgresql.org/issues/7100>`_ - Fixed an issue where the Browser tree gets disappears when scrolling sequences.
|
||||||
| `Issue #7109 <https://redmine.postgresql.org/issues/7109>`_ - Make the size blank for all the directories in the file select dialog.
|
| `Issue #7109 <https://redmine.postgresql.org/issues/7109>`_ - Make the size blank for all the directories in the file select dialog.
|
||||||
|
| `Issue #7110 <https://redmine.postgresql.org/issues/7110>`_ - Ensure that cursor should be focused on the first options of the Utility dialogs.
|
||||||
| `Issue #7118 <https://redmine.postgresql.org/issues/7118>`_ - Ensure that JSON files should be downloaded properly from the storage manager.
|
| `Issue #7118 <https://redmine.postgresql.org/issues/7118>`_ - Ensure that JSON files should be downloaded properly from the storage manager.
|
||||||
| `Issue #7123 <https://redmine.postgresql.org/issues/7123>`_ - Fixed an issue where restore generates incorrect options for the schema.
|
| `Issue #7123 <https://redmine.postgresql.org/issues/7123>`_ - Fixed an issue where restore generates incorrect options for the schema.
|
||||||
| `Issue #7126 <https://redmine.postgresql.org/issues/7126>`_ - Fixed an issue where the F2 Function key removes browser panel contents.
|
| `Issue #7126 <https://redmine.postgresql.org/issues/7126>`_ - Fixed an issue where the F2 Function key removes browser panel contents.
|
||||||
|
@ -150,7 +150,7 @@ export default function FormView({
|
|||||||
let tabsClassname = {};
|
let tabsClassname = {};
|
||||||
const [tabValue, setTabValue] = useState(0);
|
const [tabValue, setTabValue] = useState(0);
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const firstElement = useRef();
|
const firstEleSet = useRef();
|
||||||
const formRef = useRef();
|
const formRef = useRef();
|
||||||
const onScreenTracker = useRef(false);
|
const onScreenTracker = useRef(false);
|
||||||
const depListener = useContext(DepListenerContext);
|
const depListener = useContext(DepListenerContext);
|
||||||
@ -201,6 +201,8 @@ export default function FormView({
|
|||||||
}, [stateUtils.formResetKey]);
|
}, [stateUtils.formResetKey]);
|
||||||
|
|
||||||
let fullTabs = [];
|
let fullTabs = [];
|
||||||
|
// To check if the first element ref is set.
|
||||||
|
firstEleSet.current = false;
|
||||||
|
|
||||||
/* Prepare the array of components based on the types */
|
/* Prepare the array of components based on the types */
|
||||||
schemaRef.current.fields.forEach((field)=>{
|
schemaRef.current.fields.forEach((field)=>{
|
||||||
@ -289,8 +291,9 @@ export default function FormView({
|
|||||||
tabs[group].push(
|
tabs[group].push(
|
||||||
useMemo(()=><MappedFormControl
|
useMemo(()=><MappedFormControl
|
||||||
inputRef={(ele)=>{
|
inputRef={(ele)=>{
|
||||||
if(firstEleRef && !firstEleRef.current) {
|
if(!firstEleSet.current && ele) {
|
||||||
firstEleRef.current = ele;
|
firstEleRef.current = ele;
|
||||||
|
firstEleSet.current = true;
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
state={value}
|
state={value}
|
||||||
@ -343,10 +346,6 @@ export default function FormView({
|
|||||||
fullTabs.push(sqlTabName);
|
fullTabs.push(sqlTabName);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(()=>{
|
|
||||||
firstElement.current && firstElement.current.focus();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
onTabChange && onTabChange(tabValue, Object.keys(tabs)[tabValue], sqlTabActive);
|
onTabChange && onTabChange(tabValue, Object.keys(tabs)[tabValue], sqlTabActive);
|
||||||
}, [tabValue]);
|
}, [tabValue]);
|
||||||
|
@ -67,12 +67,12 @@ function MappedFormControlBase({type, value, id, onChange, className, visible, i
|
|||||||
{...props} />;
|
{...props} />;
|
||||||
case 'toggle':
|
case 'toggle':
|
||||||
return <FormInputToggle name={name} value={value}
|
return <FormInputToggle name={name} value={value}
|
||||||
onChange={onTextChange} className={className}
|
onChange={onTextChange} className={className} inputRef={inputRef}
|
||||||
{...props} />;
|
{...props} />;
|
||||||
case 'color':
|
case 'color':
|
||||||
return <FormInputColor name={name} value={value} onChange={onTextChange} className={className} {...props} />;
|
return <FormInputColor name={name} value={value} onChange={onTextChange} className={className} {...props} />;
|
||||||
case 'file':
|
case 'file':
|
||||||
return <FormInputFileSelect name={name} value={value} onChange={onTextChange} className={className} {...props} />;
|
return <FormInputFileSelect name={name} value={value} onChange={onTextChange} className={className} inputRef={inputRef} {...props} />;
|
||||||
case 'sql':
|
case 'sql':
|
||||||
return <FormInputSQL name={name} value={value} onChange={onSqlChange} className={className} noLabel={noLabel} {...props} />;
|
return <FormInputSQL name={name} value={value} onChange={onSqlChange} className={className} noLabel={noLabel} {...props} />;
|
||||||
case 'note':
|
case 'note':
|
||||||
|
@ -523,7 +523,7 @@ FormInputCheckbox.propTypes = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export function InputToggle({cid, value, onChange, options, disabled, readonly, ...props}) {
|
export const InputToggle = forwardRef(({cid, value, onChange, options, disabled, readonly, ...props}, ref) => {
|
||||||
return (
|
return (
|
||||||
<ToggleButtonGroup
|
<ToggleButtonGroup
|
||||||
id={cid}
|
id={cid}
|
||||||
@ -533,11 +533,11 @@ export function InputToggle({cid, value, onChange, options, disabled, readonly,
|
|||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
(options||[]).map((option)=>{
|
(options||[]).map((option, i)=>{
|
||||||
const isSelected = option.value === value;
|
const isSelected = option.value === value;
|
||||||
const isDisabled = disabled || option.disabled || (readonly && !isSelected);
|
const isDisabled = disabled || option.disabled || (readonly && !isSelected);
|
||||||
return (
|
return (
|
||||||
<ToggleButton key={option.label} value={option.value} component={isSelected ? PrimaryButton : DefaultButton}
|
<ToggleButton ref={i==0 ? ref : null} key={option.label} value={option.value} component={isSelected ? PrimaryButton : DefaultButton}
|
||||||
disabled={isDisabled} aria-label={option.label}>
|
disabled={isDisabled} aria-label={option.label}>
|
||||||
<CheckRoundedIcon style={{visibility: isSelected ? 'visible': 'hidden'}}/> {option.label}
|
<CheckRoundedIcon style={{visibility: isSelected ? 'visible': 'hidden'}}/> {option.label}
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
@ -546,7 +546,8 @@ export function InputToggle({cid, value, onChange, options, disabled, readonly,
|
|||||||
}
|
}
|
||||||
</ToggleButtonGroup>
|
</ToggleButtonGroup>
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
InputToggle.displayName = 'InputToggle';
|
||||||
InputToggle.propTypes = {
|
InputToggle.propTypes = {
|
||||||
cid: PropTypes.string,
|
cid: PropTypes.string,
|
||||||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
|
||||||
@ -559,10 +560,9 @@ InputToggle.propTypes = {
|
|||||||
|
|
||||||
export function FormInputToggle({hasError, required, label,
|
export function FormInputToggle({hasError, required, label,
|
||||||
className, helpMessage, testcid, ...props}) {
|
className, helpMessage, testcid, ...props}) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormInput required={required} label={label} error={hasError} className={className} helpMessage={helpMessage} testcid={testcid}>
|
<FormInput required={required} label={label} error={hasError} className={className} helpMessage={helpMessage} testcid={testcid}>
|
||||||
<InputToggle {...props}/>
|
<InputToggle ref={props.inputRef} {...props}/>
|
||||||
</FormInput>
|
</FormInput>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -573,6 +573,7 @@ FormInputToggle.propTypes = {
|
|||||||
className: CustomPropTypes.className,
|
className: CustomPropTypes.className,
|
||||||
helpMessage: PropTypes.string,
|
helpMessage: PropTypes.string,
|
||||||
testcid: PropTypes.string,
|
testcid: PropTypes.string,
|
||||||
|
inputRef: CustomPropTypes.ref
|
||||||
};
|
};
|
||||||
|
|
||||||
/* react-select package is used for select input
|
/* react-select package is used for select input
|
||||||
@ -739,8 +740,8 @@ function getRealValue(options, value, creatable, formatter) {
|
|||||||
return realValue;
|
return realValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function InputSelect({
|
export const InputSelect = forwardRef(({
|
||||||
cid, onChange, options, readonly=false, value, controlProps={}, optionsLoaded, optionsReloadBasis, disabled, ...props}) {
|
cid, onChange, options, readonly=false, value, controlProps={}, optionsLoaded, optionsReloadBasis, disabled, ...props}, ref) => {
|
||||||
const [[finalOptions, isLoading], setFinalOptions] = useState([[], true]);
|
const [[finalOptions, isLoading], setFinalOptions] = useState([[], true]);
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
@ -831,14 +832,15 @@ export function InputSelect({
|
|||||||
};
|
};
|
||||||
if(!controlProps.creatable) {
|
if(!controlProps.creatable) {
|
||||||
return (
|
return (
|
||||||
<Select {...commonProps}/>
|
<Select ref={ref} {...commonProps}/>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<CreatableSelect {...commonProps}/>
|
<CreatableSelect ref={ref} {...commonProps}/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
InputSelect.displayName = 'InputSelect';
|
||||||
InputSelect.propTypes = {
|
InputSelect.propTypes = {
|
||||||
cid: PropTypes.string,
|
cid: PropTypes.string,
|
||||||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array, PropTypes.bool]),
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array, PropTypes.bool]),
|
||||||
@ -854,10 +856,9 @@ InputSelect.propTypes = {
|
|||||||
|
|
||||||
export function FormInputSelect({
|
export function FormInputSelect({
|
||||||
hasError, required, className, label, helpMessage, testcid, ...props}) {
|
hasError, required, className, label, helpMessage, testcid, ...props}) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormInput required={required} label={label} error={hasError} className={className} helpMessage={helpMessage} testcid={testcid}>
|
<FormInput required={required} label={label} error={hasError} className={className} helpMessage={helpMessage} testcid={testcid}>
|
||||||
<InputSelect {...props}/>
|
<InputSelect ref={props.inputRef} {...props}/>
|
||||||
</FormInput>
|
</FormInput>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -868,6 +869,7 @@ FormInputSelect.propTypes = {
|
|||||||
className: CustomPropTypes.className,
|
className: CustomPropTypes.className,
|
||||||
helpMessage: PropTypes.string,
|
helpMessage: PropTypes.string,
|
||||||
testcid: PropTypes.string,
|
testcid: PropTypes.string,
|
||||||
|
inputRef: CustomPropTypes.ref
|
||||||
};
|
};
|
||||||
|
|
||||||
/* React wrapper on color pickr */
|
/* React wrapper on color pickr */
|
||||||
|
Loading…
Reference in New Issue
Block a user