Skip to content

Commit 620c037

Browse files
committed
Fixed addprops native mode bug
1 parent 840e440 commit 620c037

File tree

3 files changed

+39
-13
lines changed

3 files changed

+39
-13
lines changed

src/components/bottom/BottomPanel.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component } from 'react';
22
import { connect } from 'react-redux';
3-
import { handleClose, deleteProp, addProp, toggleNative } from '../../actions/actionCreators';
3+
import { handleClose, deleteProp, addProp, toggleNative, changeComponentFocusChild } from '../../actions/actionCreators';
44
import BottomTabs from './BottomTabs';
55
import { PropsInt, PropInt } from '../../interfaces/Interfaces';
66
import { toggleCodeEdit } from '../../actions/actionCreators';
@@ -12,7 +12,7 @@ const mapDispatchToProps = (dispatch: any) => ({
1212
deleteProp: (id: number) => dispatch(deleteProp(id)),
1313
handleNotificationClose: () => dispatch(handleClose()),
1414
toggleNative: () => dispatch(toggleNative()),
15-
toggleCodeEdit: () => dispatch(toggleCodeEdit())
15+
toggleCodeEdit: () => dispatch(toggleCodeEdit()),
1616
});
1717

1818
const mapStateToProps = (store: any) => ({
@@ -31,6 +31,10 @@ interface BottomPanelPropsInt extends PropsInt {
3131
native: boolean;
3232
toggleCodeEdit(): void;
3333
codeReadOnly: boolean;
34+
changeComponentFocusChild(arg: {
35+
componentId: number;
36+
childId: number;
37+
}): void;
3438
}
3539

3640
class BottomPanel extends Component<BottomPanelPropsInt> {
@@ -46,7 +50,8 @@ class BottomPanel extends Component<BottomPanelPropsInt> {
4650
toggleNative,
4751
native,
4852
toggleCodeEdit,
49-
codeReadOnly
53+
codeReadOnly,
54+
changeComponentFocusChild
5055
} = this.props;
5156

5257
return (

src/components/bottom/BottomTabs.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Props from './Props';
88
import HtmlAttr from './HtmlAttr';
99
import CodePreview from './CodePreview';
1010
import Switch from '@material-ui/core/Switch';
11-
import { ComponentsInt, PropInt, PropsInt } from '../../interfaces/Interfaces';
11+
import { ComponentsInt, PropsInt } from '../../interfaces/Interfaces';
1212
import Box from '@material-ui/core/Box';
1313
import FormGroup from '@material-ui/core/FormGroup';
1414
import FormControlLabel from '@material-ui/core/FormControlLabel';
@@ -36,7 +36,7 @@ const styles = (theme: Theme): any => ({
3636
backgroundColor: '#333333',
3737
height: '100%',
3838
color: '#fff',
39-
boxShadow: '0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)',
39+
boxShadow: '0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)'
4040
},
4141
bottomHeader: {
4242
flex: 1,
@@ -211,17 +211,23 @@ class BottomTabs extends Component<BottomTabsPropsInt, StateInt> {
211211
<FormGroup>
212212
<FormControlLabel
213213
className={classes.switch}
214-
control={<Switch checked={native} color="primary" onChange={() => {
215-
toggleNative();
216-
}} />}
214+
control={
215+
<Switch
216+
checked={native}
217+
color="primary"
218+
onChange={() => {
219+
toggleNative();
220+
}}
221+
/>
222+
}
217223
label="Native Mode"
218224
labelPlacement="start"
219225
/>
220226
</FormGroup>
221227
</Box>
222228
{value === 0 && (
223229
<div
224-
id='treeWrapper'
230+
id="treeWrapper"
225231
style={{
226232
width: '80%',
227233
height: '100%'

src/components/bottom/Props.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ import TextField from '@material-ui/core/TextField';
77
import Button from '@material-ui/core/Button';
88
import Select from '@material-ui/core/Select';
99
import InputLabel from '@material-ui/core/InputLabel';
10-
import { addProp, deleteProp } from '../../actions/actionCreators';
10+
import { addProp, changeComponentFocusChild, deleteProp } from '../../actions/actionCreators';
1111
import DataTable from './DataTable';
1212
import { PropInt, PropsInt } from '../../interfaces/Interfaces';
1313

1414
interface PropsPropsInt extends PropsInt {
1515
classes: any;
1616
addProp(arg: PropInt): void;
1717
deleteProp(propId: number): void;
18+
changeComponentFocusChild(arg: {
19+
componentId: number;
20+
childId: number;
21+
}): void;
1822
}
1923

2024
const styles = () => ({
@@ -136,11 +140,19 @@ const styles = () => ({
136140

137141
const mapDispatchToProps = (dispatch: any) => ({
138142
addProp: (prop: PropInt) => dispatch(addProp(prop)),
139-
deleteProp: (propId: number) => dispatch(deleteProp(propId))
143+
deleteProp: (propId: number) => dispatch(deleteProp(propId)),
144+
changeComponentFocusChild: ({
145+
componentId,
146+
childId
147+
}: {
148+
componentId: number;
149+
childId: number;
150+
}) => dispatch(changeComponentFocusChild({ componentId, childId })),
140151
});
141152

142153
const mapStateToProps = (store: any) => ({
143-
focusComponent: store.workspace.focusComponent
154+
focusComponent: store.workspace.focusComponent,
155+
focusChild: store.workspace.focusChild
144156
});
145157

146158
// available types for select drop-down for button types
@@ -187,7 +199,7 @@ class Props extends Component<PropsPropsInt, StateInt> {
187199

188200
// using useState to locally check a clickedValue
189201

190-
handleChange = (event: MouseEvent | any) => {
202+
handleChange = (event: any) => {
191203
if (event.target.id === 'propVariable') {
192204
this.setState({
193205
[event.target.id]: event.target.value.trim()
@@ -239,12 +251,15 @@ class Props extends Component<PropsPropsInt, StateInt> {
239251
type: propType
240252
});
241253

254+
this.props.changeComponentFocusChild({ componentId: this.props.focusComponent.id , childId: this.props.focusChild.childId});
242255
this.setState({
243256
propVariable: '',
244257
propValue: '',
245258
propRequired: true,
246259
propType: ''
247260
});
261+
262+
248263
};
249264

250265
render() {

0 commit comments

Comments
 (0)