Skip to content

Commit

Permalink
only update the current time entry when the description was actually …
Browse files Browse the repository at this point in the history
…changed, not on all blur
  • Loading branch information
Onatcer committed Aug 8, 2024
1 parent 16203ec commit b741105
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions resources/js/Components/Common/TimeTracker/TimeTrackerControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
TimeEntry,
Client,
} from '@/utils/api';
import { ref } from 'vue';
import { ref, watch } from 'vue';
import type { Dayjs } from 'dayjs';
const currentTimeEntry = defineModel<TimeEntry>('currentTimeEntry', {
Expand Down Expand Up @@ -70,6 +70,19 @@ function onToggleButtonPress(newState: boolean) {
emit('stopTimer');
}
}
const tempDescription = ref(currentTimeEntry.value.description);
watch(
() => currentTimeEntry.value.description,
() => {
tempDescription.value = currentTimeEntry.value.description;
}
);
function updateTimeEntryDescription() {
if (currentTimeEntry.value.description !== tempDescription.value) {
currentTimeEntry.value.description = tempDescription.value;
emit('updateTimeEntry');
}
}
</script>

<template>
Expand All @@ -83,9 +96,9 @@ function onToggleButtonPress(newState: boolean) {
placeholder="What are you working on?"
data-testid="time_entry_description"
ref="currentTimeEntryDescriptionInput"
v-model="currentTimeEntry.description"
v-model="tempDescription"
@keydown.enter="startTimerIfNotActive"
@blur="$emit('updateTimeEntry')"
@blur="updateTimeEntryDescription"
class="w-full rounded-l-lg py-4 sm:py-2.5 px-3.5 border-b border-b-card-background-separator lg:px-4 text-base @4xl:text-lg text-white font-medium bg-transparent border-none placeholder-muted focus:ring-0 transition"
type="text" />
</div>
Expand Down

0 comments on commit b741105

Please sign in to comment.