Skip to content

Commit 1acccbb

Browse files
committed
fixed useStateModal's component buttons to refresh the modal view to topmost component state when clicked. code preview keystring is also refreshed with this click now.
co-authored-by: Crys Lim [email protected]
1 parent e13c20e commit 1acccbb

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

app/src/components/bottom/UseStateModal.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ function UseStateModal({ updateAttributeWithState, attributeToChange, childId })
1414
const [componentProviderId, setComponentProviderId] = useState(1) // for now set to App
1515
const components = [];
1616
for (let i = 0; i < state.components.length; i ++) {
17-
components.push(<button onClick={() => setComponentProviderId(i+1)}>{state.components[i].name}</button>)
17+
components.push(<button
18+
onClick={() => {
19+
setComponentProviderId(i+1);
20+
setDisplayObject(null);
21+
setStateKey('');
22+
}}>
23+
{state.components[i].name}
24+
</button>)
1825
}
1926

2027
// return the selected state's ID back so the value of it can be updated in the customizationpanel. to the assign the value of selected state to attribute tied to useState button (currently just text)

app/src/helperFunctions/generateCode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const generateUnformattedCode = (
126126
const elementGenerator = (childElement: object, level: number = 2) => {
127127
let innerText = '';
128128
let activeLink = '';
129-
129+
130130
if (childElement.attributes && childElement.attributes.compText) {
131131
if (childElement.stateUsed && childElement.stateUsed.compText) {
132132
innerText = '{' + childElement.stateUsed.compText + '}';

0 commit comments

Comments
 (0)