Skip to content

Commit

Permalink
hotfix: PC 환경에서 하나씩 클릭되지 않는 문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
corinthionia committed Aug 7, 2023
1 parent 2b24b63 commit dca79ec
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions src/components/addTimeTable/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ const Table = ({
}, [selectedMethod, isResetButtonClick]);

const handleCellSelect = (e: any) => {
e.added.forEach((el: any) => {
el.classList.add('selected');
});
if (e.inputEvent.type !== 'touchstart') {
e.added.forEach((el: any) => {
el.classList.add('selected');
});

e.removed.forEach((el: any) => {
el.classList.remove('selected');
});
e.removed.forEach((el: any) => {
el.classList.remove('selected');
});
}
};

const addSelectedToObject = () => {
Expand All @@ -70,15 +72,19 @@ const Table = ({
setSelected(newObj);
};

const handleClickOneElement = (e: React.MouseEvent<HTMLDivElement>) => {
const handleClickOneElement = (
e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>
) => {
const target = e.target as HTMLDivElement;

if (target.classList.contains('valid')) {
if (target.classList.contains('selected')) {
target.classList.remove('selected');
} else {
target.classList.add('selected');
addSelectedToObject();
if (e.type === 'click') {
if (target.classList.contains('valid')) {
if (target.classList.contains('selected')) {
target.classList.remove('selected');
} else {
target.classList.add('selected');
addSelectedToObject();
}
}
}
};
Expand Down Expand Up @@ -122,11 +128,13 @@ const Table = ({
selectFromInside={true}
continueSelect={true}
continueSelectWithoutDeselect={false}
selectByClick={false}
ratio={0}
/>
{timeDetail.map((time) => (
<Select
onMouseUp={handleClickOneElement}
onClick={handleClickOneElement}
onTouchStart={handleClickOneElement}
className={isValidDate ? 'valid' : 'invalid'}
key={`${date} ${time}:00`}
id={`${date} ${time}`}
Expand Down

0 comments on commit dca79ec

Please sign in to comment.