mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2025-02-17 17:40:31 +08:00
fix(editor): prevent API and state form keyboard events to accidentally trigger operation shortcut
This commit is contained in:
parent
42759fd157
commit
b0eb0921e2
@ -95,6 +95,10 @@ export const ApiForm: React.FC<Props> = props => {
|
||||
setTabIndex(0);
|
||||
}
|
||||
};
|
||||
const onKeyDown = (e: React.KeyboardEvent) => {
|
||||
// prevent form keyboard events to accidentally trigger operation shortcut
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
formik.setValues({
|
||||
@ -116,6 +120,7 @@ export const ApiForm: React.FC<Props> = props => {
|
||||
paddingBottom="0"
|
||||
align="stretch"
|
||||
spacing="4"
|
||||
onKeyDown={onKeyDown}
|
||||
>
|
||||
<HStack
|
||||
alignItems="center"
|
||||
|
@ -36,15 +36,18 @@ export const DataSource: React.FC<Props> = props => {
|
||||
const { apis, states } = editorStore.dataSources;
|
||||
const onMenuItemClick = (type: DataSourceType) => {
|
||||
editorStore.createDataSource(type);
|
||||
editorStore.setSelectedComponentId('');
|
||||
};
|
||||
const onApiItemClick = (api: ComponentSchema) => {
|
||||
editorStore.setActiveDataSource(api);
|
||||
editorStore.setActiveDataSourceType(DataSourceType.API);
|
||||
editorStore.setSelectedComponentId('');
|
||||
};
|
||||
const onStateItemClick = (state: ComponentSchema) => {
|
||||
editorStore.setActiveDataSource(state);
|
||||
editorStore.setActiveDataSourceType(DataSourceType.STATE);
|
||||
editorStore.setToolMenuTab(ToolMenuTabs.INSPECT);
|
||||
editorStore.setSelectedComponentId('');
|
||||
};
|
||||
const onApiItemRemove = (api: ComponentSchema) => {
|
||||
editorStore.removeDataSource(api);
|
||||
|
@ -47,6 +47,10 @@ export const StateForm: React.FC<Props> = props => {
|
||||
}
|
||||
}
|
||||
};
|
||||
const onKeyDown = (e: React.KeyboardEvent) => {
|
||||
// prevent form keyboard events to accidentally trigger operation shortcut
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
formik.setValues({
|
||||
@ -61,7 +65,7 @@ export const StateForm: React.FC<Props> = props => {
|
||||
}, [state.id]);
|
||||
|
||||
return (
|
||||
<VStack p="2" spacing="2" background="gray.50">
|
||||
<VStack p="2" spacing="2" background="gray.50" onKeyDown={onKeyDown}>
|
||||
<FormControl>
|
||||
<FormLabel>Name</FormLabel>
|
||||
<Input
|
||||
|
@ -89,9 +89,11 @@ export class EditorStore {
|
||||
reaction(
|
||||
() => this.selectedComponentId,
|
||||
() => {
|
||||
this.setToolMenuTab(ToolMenuTabs.INSPECT);
|
||||
this.setActiveDataSource(null);
|
||||
this.setActiveDataSourceType(null);
|
||||
if (this.selectedComponentId) {
|
||||
this.setToolMenuTab(ToolMenuTabs.INSPECT);
|
||||
this.setActiveDataSource(null);
|
||||
this.setActiveDataSourceType(null);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user