Skip to content

Commit

Permalink
Merge pull request #245 from open-source-labs/rose/fixes
Browse files Browse the repository at this point in the history
Final ReacType v19
  • Loading branch information
Skilzsz committed Jan 11, 2024
2 parents e9dc796 + 7ee442d commit 193d965
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
1 change: 1 addition & 0 deletions __tests__/DragAndDrop.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('Drag and Drop Side Panel', () => {
expect(screen.getByText('Root Components')).toBeInTheDocument();
expect(screen.getByText('Reusable Components')).toBeInTheDocument();
});

test('test drag and drop', () => {
render(
TestContext(
Expand Down
4 changes: 2 additions & 2 deletions __tests__/signIn.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ describe('sign in page', () => {
render(<TestSignIn />);
expect(screen.getByTestId('password-input')).toBeInTheDocument();
});
test('should render 4 login buttons and dark mode button', () => {
test('should render 4 login buttons', () => {
render(<TestSignIn />);
expect(screen.getAllByRole('button')).toHaveLength(5);
expect(screen.getAllByRole('button')).toHaveLength(4);
});
test('should invalidate empty username field', () => {
render(<TestSignIn />);
Expand Down
17 changes: 5 additions & 12 deletions app/src/components/left/HTMLPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,11 @@ const HTMLPanel = (props): JSX.Element => {
const [alertOpen, setAlertOpen] = React.useState<boolean>(false);
const state = useSelector((store: RootState) => store.appState);
const roomCode = useSelector((store: RootState) => store.roomSlice.roomCode);
const currentID = useSelector(
(store: RootState) => store.appState.customElementId
);

const dispatch = useDispatch();
let startingID = 0;
state.HTMLTypes.forEach((element) => {
if (element.id >= startingID) startingID = element.id;
});
startingID += 1;

const [currentID, setCurrentID] = useState(startingID);

const buttonClasses =
'MuiButtonBase-root MuiButton-root MuiButton-text makeStyles-button-12 MuiButton-textPrimary';

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

setCurrentID(currentID + 1);
// setCurrentID(currentID + 1);
setTag('');
setName('');
};
Expand Down Expand Up @@ -324,7 +317,7 @@ const useStyles = makeStyles({
width: '100%'
},
addComponentWrapper: {
width: '100%',
width: '100%'
},
input: {
borderRadius: '5px',
Expand Down
1 change: 1 addition & 0 deletions app/src/interfaces/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface State {
stylesheet: string;
codePreview: boolean;
screenshotTrigger: boolean;
customElementId: number;
}

export interface ChildElement {
Expand Down
4 changes: 3 additions & 1 deletion app/src/redux/reducers/slice/appStateSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export const initialState: State = {
tailwind: false,
stylesheet: '',
codePreview: false,
screenshotTrigger: false
screenshotTrigger: false,
customElementId: 10001
};

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

0 comments on commit 193d965

Please sign in to comment.