Skip to content

Commit 0534db2

Browse files
fix(web): pasting over a held retention age saves it once
NumberField applies a paste itself, so the input's change event never fired and the held age stayed set: leaving the row then saved the pasted age from both the field's blur commit and the row's held commit. A paste now drops the held age like a typed edit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d49890f commit 0534db2

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎apps/web/src/components/settings/StorageSettings.browser.test.tsx‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,28 @@ it("saves an edited draft when focus leaves its row", async () => {
192192
});
193193
});
194194

195+
it("saves an age pasted over a held age once", async () => {
196+
setup();
197+
await using screen = await render(panel());
198+
await userEvent.click(ruleSwitch(screen));
199+
await userEvent.fill(daysInput(screen), "30");
200+
await userEvent.tab();
201+
await userEvent.tab({ shift: true });
202+
const clipboardData = new DataTransfer();
203+
clipboardData.setData("text/plain", "60");
204+
await act(async () => {
205+
daysInput(screen)
206+
.element()
207+
.dispatchEvent(
208+
new ClipboardEvent("paste", { clipboardData, bubbles: true, cancelable: true }),
209+
);
210+
});
211+
await userEvent.click(screen.getByRole("heading", { name: rule }));
212+
expect(state.update).toHaveBeenCalledExactlyOnceWith({
213+
storageCleanup: { browserArtifactsAfterDays: 60 },
214+
});
215+
});
216+
195217
it("saves a stepped first age only once it is committed", async () => {
196218
setup();
197219
await using screen = await render(panel());

‎apps/web/src/components/settings/StorageSettings.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,10 @@ function RetentionControl({
188188
autoFocus={value === null}
189189
size={new Intl.NumberFormat().format(draft ?? value ?? 8).length}
190190
className="field-sizing-content w-auto min-w-[1ch] grow-0 text-right"
191-
// Any edit, even one NumberField cannot parse yet, replaces a held age.
191+
// Any typed or pasted edit replaces a held age: NumberField commits it on blur itself,
192+
// and text it cannot parse yet must not leave the held age to be saved.
192193
onChange={() => setHeld(false)}
194+
onPaste={() => setHeld(false)}
193195
onKeyDown={(event) => {
194196
if (event.nativeEvent.isComposing || event.keyCode === 229) return;
195197
if (event.key === "Enter") {

0 commit comments

Comments
 (0)