Skip to content

Rose/fixes #245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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