Skip to content

Commit 2fbfdd4

Browse files
committed
fix: keep values in cells that have a stored value after blur
closes #109
1 parent e1fe29d commit 2fbfdd4

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/app/components/base/currency-cell/CurrencyCell.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ watch(modelValue, (value, oldValue) => {
6868
});
6969
7070
watch(focused, (value) => {
71-
if (value) return;
71+
if (value) {
72+
innerValue.value ??= modelValue.value ? String(modelValue.value) : undefined;
73+
return;
74+
}
7275
7376
const trimmed = innerValue.value?.trim();
7477
if (!trimmed) {

test/budgets.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test('Show correct budget group totals and averages', async ({ page }) => {
3131
await expect(page.getByTestId('group-0-budget-0-average')).toContainText('€125');
3232
});
3333

34-
test('Evaluate expressions correctly without erors', async ({ page }) => {
34+
test('Evaluate expressions correctly without errors', async ({ page }) => {
3535
await page.goto('/income');
3636

3737
// Simple expressions

test/tools.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ test('Load demo data', async ({ page }) => {
1212
await expect(page.getByTestId('income-value')).toHaveText('€108,600');
1313
});
1414

15+
test('Keep value in cells if unchanged', async ({ page }) => {
16+
await page.goto('/#demo');
17+
await page.getByTestId('navigation-income').click();
18+
const value = await page.getByTestId('group-0-budget-0-0').inputValue();
19+
20+
await page.getByTestId('group-0-budget-0-0').focus();
21+
await page.getByTestId('group-0-budget-0-0').blur();
22+
await expect(page.getByTestId('group-0-budget-0-0')).toHaveValue(value);
23+
});
24+
1525
test('Copy data from one year to another', async ({ page }) => {
1626
await page.goto('/#demo');
1727
await expect(page.getByTestId('income-value')).toHaveText('€108,600');

0 commit comments

Comments
 (0)