Skip to content
This repository has been archived by the owner on Jan 2, 2022. It is now read-only.

Commit

Permalink
fix: tasks behind sidebar when dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmnunes committed Jun 6, 2020
1 parent d144138 commit c80ac85
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const StyledBoardHeader = styled.div`
align-items: flex-start;
width: 100%;
position: sticky;
z-index: 5000;
z-index: 998;
top: 0;
padding-top: 48px;
background: white;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/day/SideBar/SideBar.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const StyledSidebar = styled.div<{ isOpen?: boolean }>`
overflow-y: auto;
background: ${({ theme }) => theme.yellow050};
position: fixed;
z-index: 20000;
z-index: 999;
right: 0;
transform: ${({ isOpen }) => `translateX(${isOpen ? 0 : '448px'})`};
transition: transform 0.2s ease;
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/features/day/api/useToggleActiveTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ export const useToggleActiveTask = () => {

// If "this" is not the active task ➜ start it
if (activeTaskId !== task.id) {
const start = moment.utc().toISOString();

updateTask({
taskId: task.id,
body: {
sectionId,
dayId,
payload: {
start: moment.utc().toISOString(),
start,
},
},
});
Expand All @@ -59,7 +61,7 @@ export const useToggleActiveTask = () => {
taskId: task.id,
sectionId,
dayId,
start: moment.utc().toISOString(),
start,
} as ActiveTaskDto);
} else {
queryCache.setQueryData('activeTask', emptyActiveTask);
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/features/day/api/useUpdateTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export const useUpdateTask = () => {
const previousDay = queryCache.getQueryData(['day', dayId]);
const scopes = queryCache.getQueryData('scopes') as ScopeDto[];

const previousActiveTask = queryCache.getQueryData('activeTask');

queryCache.setQueryData<DayDto | undefined>(['day', dayId], currentDay => {
if (currentDay) {
const sectionIndex = currentDay.sections.findIndex(({ id }) => id === sectionId);
Expand Down Expand Up @@ -70,7 +72,10 @@ export const useUpdateTask = () => {
return currentDay;
});

return () => queryCache.setQueryData(['day', dayId], previousDay);
return () => {
queryCache.setQueryData(['day', dayId], previousDay);
queryCache.setQueryData('activeTask', previousActiveTask);
};
},

onError: (_, __, rollback) => {
Expand Down

0 comments on commit c80ac85

Please # to comment.