Skip to content

Commit

Permalink
390 bugfix large modal hotkeys (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathildehaugum authored Dec 12, 2023
1 parent d25df06 commit ffb0bdc
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export function AddEngagementHoursRow({
const [currentDragWeek, setCurrentDragWeek] = useState<number | undefined>(
undefined,
);
const [isRowHovered, setIsRowHovered] = useState(false);
const [consultantWHours, setConsultantsWHours] = useState<
ConsultantWithWeekHours | undefined
>(consultantWWeekHours);
Expand Down Expand Up @@ -90,8 +89,6 @@ export function AddEngagementHoursRow({
setHourDragValue={setHourDragValue}
setStartDragWeek={setStartDragWeek}
setCurrentDragWeek={setCurrentDragWeek}
isRowHovered={isRowHovered}
setIsRowHovered={setIsRowHovered}
numWeeks={weekList.length}
firstDayInWeek={day}
initHours={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ export function DetailedEngagementModalCell({
startDragWeek,
setStartDragWeek,
setCurrentDragWeek,
isRowHovered,
setIsRowHovered,
numWeeks,
firstDayInWeek,
initHours,
Expand All @@ -36,8 +34,6 @@ export function DetailedEngagementModalCell({
setHourDragValue: React.Dispatch<React.SetStateAction<number | undefined>>;
setStartDragWeek: React.Dispatch<React.SetStateAction<number | undefined>>;
setCurrentDragWeek: React.Dispatch<React.SetStateAction<number | undefined>>;
isRowHovered: boolean;
setIsRowHovered: React.Dispatch<React.SetStateAction<boolean>>;
numWeeks: number;
firstDayInWeek: DateTime;
initHours: number;
Expand All @@ -46,14 +42,12 @@ export function DetailedEngagementModalCell({
const [hours, setHours] = useState(initHours);
const [isChangingHours, setIsChangingHours] = useState(false);
const [oldHours, setOldHours] = useState(0);
const { setIsDisabledHotkeys } = useContext(FilteredContext);

const [isInputFocused, setIsInputFocused] = useState(false);
const inputRef = useRef<HTMLInputElement | null>(null);
const organisationName = usePathname().split("/")[1];

function updateSingularHours() {
setIsDisabledHotkeys(false);
if (oldHours != hours && hourDragValue == undefined) {
setOldHours(hours);
setDetailedBookingHours({
Expand All @@ -69,14 +63,7 @@ export function DetailedEngagementModalCell({
}
}

useEffect(() => {
if (!isRowHovered && inputRef.current) {
inputRef.current.blur();
}
}, [isRowHovered]);

function updateDragHours() {
setIsDisabledHotkeys(false);
if (
hourDragValue == undefined ||
startDragWeek == undefined ||
Expand Down Expand Up @@ -134,10 +121,8 @@ export function DetailedEngagementModalCell({
}`}
onMouseEnter={() => {
setIsChangingHours(true);
setIsRowHovered(true);
}}
onMouseLeave={() => {
setIsRowHovered(false);
setIsChangingHours(false);
!isInputFocused && updateSingularHours();
}}
Expand Down Expand Up @@ -176,12 +161,10 @@ export function DetailedEngagementModalCell({
onFocus={(e) => {
e.target.select();
setIsInputFocused(true);
setIsDisabledHotkeys(true);
}}
onBlur={() => {
updateSingularHours();
setIsInputFocused(false);
setIsDisabledHotkeys(false);
}}
onDragStart={() => {
setHourDragValue(hours);
Expand Down
15 changes: 0 additions & 15 deletions frontend/src/components/Staffing/DetailedBookingRows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export function DetailedBookingRows(props: {
const [currentDragWeek, setCurrentDragWeek] = useState<number | undefined>(
undefined,
);
const [isRowHovered, setIsRowHovered] = useState(false);

const [editOfferDropdownIsOpen, setEditOfferDropdownIsOpen] = useState(false);
const menuRef = useRef(null);
Expand Down Expand Up @@ -167,8 +166,6 @@ export function DetailedBookingRows(props: {
startDragWeek={startDragWeek}
setStartDragWeek={setStartDragWeek}
setCurrentDragWeek={setCurrentDragWeek}
isRowHovered={isRowHovered}
setIsRowHovered={setIsRowHovered}
/>
))}
</tr>
Expand Down Expand Up @@ -217,8 +214,6 @@ function DetailedBookingCell({
startDragWeek,
setStartDragWeek,
setCurrentDragWeek,
isRowHovered,
setIsRowHovered,
}: {
detailedBooking: DetailedBooking;
detailedBookingHours: WeeklyHours;
Expand All @@ -229,8 +224,6 @@ function DetailedBookingCell({
setHourDragValue: React.Dispatch<React.SetStateAction<number | undefined>>;
setStartDragWeek: React.Dispatch<React.SetStateAction<number | undefined>>;
setCurrentDragWeek: React.Dispatch<React.SetStateAction<number | undefined>>;
isRowHovered: boolean;
setIsRowHovered: React.Dispatch<React.SetStateAction<boolean>>;
}) {
const { setConsultants } = useContext(FilteredContext);
const [hours, setHours] = useState(detailedBookingHours.hours);
Expand Down Expand Up @@ -262,12 +255,6 @@ function DetailedBookingCell({
}
}

useEffect(() => {
if (!isRowHovered && inputRef.current) {
inputRef.current.blur();
}
}, [isRowHovered]);

useEffect(() => {
setHours(detailedBookingHours.hours);
setOldHours(detailedBookingHours.hours);
Expand Down Expand Up @@ -326,10 +313,8 @@ function DetailedBookingCell({
}`}
onMouseEnter={() => {
setIsChangingHours(true);
setIsRowHovered(true);
}}
onMouseLeave={() => {
setIsRowHovered(false);
setIsChangingHours(false);
!isInputFocused && updateSingularHours();
}}
Expand Down

0 comments on commit ffb0bdc

Please sign in to comment.