Skip to content

Commit 193d965

Browse files
authored
Merge pull request #245 from open-source-labs/rose/fixes
Final ReacType v19
2 parents e9dc796 + 7ee442d commit 193d965

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

__tests__/DragAndDrop.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ describe('Drag and Drop Side Panel', () => {
5555
expect(screen.getByText('Root Components')).toBeInTheDocument();
5656
expect(screen.getByText('Reusable Components')).toBeInTheDocument();
5757
});
58+
5859
test('test drag and drop', () => {
5960
render(
6061
TestContext(

__tests__/signIn.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ describe('sign in page', () => {
2525
render(<TestSignIn />);
2626
expect(screen.getByTestId('password-input')).toBeInTheDocument();
2727
});
28-
test('should render 4 login buttons and dark mode button', () => {
28+
test('should render 4 login buttons', () => {
2929
render(<TestSignIn />);
30-
expect(screen.getAllByRole('button')).toHaveLength(5);
30+
expect(screen.getAllByRole('button')).toHaveLength(4);
3131
});
3232
test('should invalidate empty username field', () => {
3333
render(<TestSignIn />);

app/src/components/left/HTMLPanel.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,11 @@ const HTMLPanel = (props): JSX.Element => {
3434
const [alertOpen, setAlertOpen] = React.useState<boolean>(false);
3535
const state = useSelector((store: RootState) => store.appState);
3636
const roomCode = useSelector((store: RootState) => store.roomSlice.roomCode);
37+
const currentID = useSelector(
38+
(store: RootState) => store.appState.customElementId
39+
);
3740

3841
const dispatch = useDispatch();
39-
let startingID = 0;
40-
state.HTMLTypes.forEach((element) => {
41-
if (element.id >= startingID) startingID = element.id;
42-
});
43-
startingID += 1;
44-
45-
const [currentID, setCurrentID] = useState(startingID);
46-
47-
const buttonClasses =
48-
'MuiButtonBase-root MuiButton-root MuiButton-text makeStyles-button-12 MuiButton-textPrimary';
4942

5043
const handleTagChange = (e: React.ChangeEvent<HTMLInputElement>) => {
5144
resetError();
@@ -114,7 +107,7 @@ const HTMLPanel = (props): JSX.Element => {
114107
emitEvent('addElementAction', roomCode, newElement);
115108
}
116109

117-
setCurrentID(currentID + 1);
110+
// setCurrentID(currentID + 1);
118111
setTag('');
119112
setName('');
120113
};
@@ -324,7 +317,7 @@ const useStyles = makeStyles({
324317
width: '100%'
325318
},
326319
addComponentWrapper: {
327-
width: '100%',
320+
width: '100%'
328321
},
329322
input: {
330323
borderRadius: '5px',

app/src/interfaces/Interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface State {
2121
stylesheet: string;
2222
codePreview: boolean;
2323
screenshotTrigger: boolean;
24+
customElementId: number;
2425
}
2526

2627
export interface ChildElement {

app/src/redux/reducers/slice/appStateSlice.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ export const initialState: State = {
4444
tailwind: false,
4545
stylesheet: '',
4646
codePreview: false,
47-
screenshotTrigger: false
47+
screenshotTrigger: false,
48+
customElementId: 10001
4849
};
4950

5051
let separator = initialState.HTMLTypes[1];
@@ -905,6 +906,7 @@ const appStateSlice = createSlice({
905906
const HTMLTypes = [...state.HTMLTypes];
906907
HTMLTypes.push(action.payload);
907908
state.HTMLTypes = HTMLTypes;
909+
state.customElementId += 1;
908910
},
909911
//Undo & Redo functions are not working properly. Redo & Undo target the last component rather than last added HTML Element.
910912
undo: (state, action) => {

0 commit comments

Comments
 (0)