From 7c6d274bff976ef4a7b13479f5093c6dca5312f3 Mon Sep 17 00:00:00 2001 From: Damian Pieczynski Date: Sun, 29 Nov 2026 13:12:55 +0100 Subject: [PATCH 1/5] fix(virtual-core): write a hold before a command whose target is below it Written the hold short, a target less than the hold clamps at the element's 0 and the read-back retires the command. Write the hold first when the command can write (it has closed a tap's tail), then the command. Fixes #1405 --- .changeset/ios-hold-command-below-hold.md | 5 +++ packages/virtual-core/src/index.ts | 13 +++++- .../__snapshots__/scroll-trace.test.ts.snap | 6 +-- .../virtual-core/tests/ios-deferral.test.ts | 41 +++++++++++++++++++ 4 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 .changeset/ios-hold-command-below-hold.md diff --git a/.changeset/ios-hold-command-below-hold.md b/.changeset/ios-hold-command-below-hold.md new file mode 100644 index 000000000..ff438d595 --- /dev/null +++ b/.changeset/ios-hold-command-below-hold.md @@ -0,0 +1,5 @@ +--- +'@tanstack/virtual-core': patch +--- + +Fix a scroll command stopping short of a target near the top while a scroll correction is held (iOS touch, or a bounce). For example, `scrollToIndex(0)` right after a tap that grew a row above the viewport ended the size of that growth below the top. The held correction is now written first, then the command. diff --git a/packages/virtual-core/src/index.ts b/packages/virtual-core/src/index.ts index 033b9fb9e..300ced557 100644 --- a/packages/virtual-core/src/index.ts +++ b/packages/virtual-core/src/index.ts @@ -2692,7 +2692,8 @@ export class Virtualizer< // before the command (below). One held for a touch or a bounce is not // dropped by a command: the write lands the element `_holdOffset` short // of the target, under the rows exposed shifted by the same amount, and - // the flush moves both together once a write is possible. + // the flush moves both together once a write is possible. Unless the + // target is less than the hold (below). // // An index or end target that is already at its offset starts a smooth // scroll as landed; an offset target never does, so its first scroll @@ -2773,6 +2774,16 @@ export class Virtualizer< // scroll: leave it. this._iosGesture.end() } + // A target less than the hold is out of the element's reach: written + // the hold short, the write clamps at the element's 0, and the read-back + // looks like a scroll away from the target (#1405). Write the hold first + // where a write is possible now (the command has closed a tap's tail), + // as for the wheel above. Its clamp retry would write over the command. + if (offset < this._holdOffset && this._canWriteScroll()) { + this.scrollState = null + this._flushHoldIfReady(true) + this._clampedAdjustment = null + } this.scrollState = { ...target, startedAt: this.now(), diff --git a/packages/virtual-core/tests/__snapshots__/scroll-trace.test.ts.snap b/packages/virtual-core/tests/__snapshots__/scroll-trace.test.ts.snap index 4ff59755c..c045fee11 100644 --- a/packages/virtual-core/tests/__snapshots__/scroll-trace.test.ts.snap +++ b/packages/virtual-core/tests/__snapshots__/scroll-trace.test.ts.snap @@ -257,7 +257,7 @@ exports[`scroll behaviour snapshot > predicate web 1`] = ` [ "0: a888515d 54daaa9d e2050bb4 44d5f4d8 218505be 45a8c314 3bacba65 a3c61d73 be3ad9c9 65341162", "10: c449bc54 664cd3c5 ee8f5a46 b879192a 1850e117 89be8bb7 662a68a0 96f784f1 8134fb03 f9a8d78d", - "20: c6008fee 2548afff 0f7ebcdd 5d61493a d4ec59b1 19b8fe5a fe239908 4bc9f749 042a505f 8caf71f9", + "20: c6008fee 2548afff 4fe4eb99 5d61493a d4ec59b1 19b8fe5a fe239908 4bc9f749 042a505f 8caf71f9", "30: 883b3a0c 7cab4af4 9250e3e4 c4617ee9 a6405c93 046b74f7 9eeab09f f357057a bc7d089d 65080957", "40: 81e56faa a1301eb6 d5dec481 c7358748 0a4b0bb8 03a1759f 83b18626 1b8c0d8e 8e8f3238 842f2579", "50: 3b219acb 3655a421 2ca0eb37 da0b01ac ba8a46f7 84937fa5 0f598b23 0ab9d71e 6428c749 aadf8cd0", @@ -266,7 +266,7 @@ exports[`scroll behaviour snapshot > predicate web 1`] = ` exports[`scroll behaviour snapshot > smooth ios 1`] = ` [ - "0: 413b0ced 76974b95 66c9821e 3bfbda41 6c5f17be 3bf7edae ea1516fd d2c2c7b5 206ab6a1 7e0be436", + "0: 09091f4c 76974b95 66c9821e 3bfbda41 6c5f17be 3bf7edae ea1516fd d2c2c7b5 206ab6a1 7e0be436", "10: 9cebb1b0 4551cde0 621cc58e 957921f5 f1a1ad23 a18fdfbb 105e890d 756893ae 4696c4a5 30a62565", "20: a052c4c5 a8692c66 982814d7 9b2cff0c 346d6565 84e55162 c3519085 7e222fc0 7f014674 058cdf95", "30: 71c0f874 b2f398b4 484a6a70 bf605550 a5b43ec3 ed5c0a5b d63bc86d 8843c6fe 08adf872 f2174e51", @@ -277,7 +277,7 @@ exports[`scroll behaviour snapshot > smooth ios 1`] = ` exports[`scroll behaviour snapshot > smooth ios27 1`] = ` [ - "0: 413b0ced 76974b95 66c9821e b31939e8 6c5f17be 3bf7edae ea1516fd d2c2c7b5 206ab6a1 90c45313", + "0: 09091f4c 76974b95 66c9821e b31939e8 6c5f17be 3bf7edae ea1516fd d2c2c7b5 206ab6a1 90c45313", "10: f3a5a705 c07b2aec 621cc58e 957921f5 d05d020e a18fdfbb 30e7bb4d 6e2a63b1 4696c4a5 30a62565", "20: a052c4c5 f52aa31d 9e38faf7 9b2cff0c 2a78f411 84e55162 18e799f0 7e222fc0 d587a000 058cdf95", "30: 71c0f874 b2f398b4 484a6a70 2ecd0e38 27f1c0e4 ed5c0a5b d63bc86d 93d54b36 08adf872 f2174e51", diff --git a/packages/virtual-core/tests/ios-deferral.test.ts b/packages/virtual-core/tests/ios-deferral.test.ts index 75f7ef92f..f1697a2ee 100644 --- a/packages/virtual-core/tests/ios-deferral.test.ts +++ b/packages/virtual-core/tests/ios-deferral.test.ts @@ -1691,6 +1691,47 @@ test('iOS hold: a resize landing between a command and its read-back does not fl }) }) +// A command whose target is above the element's reach while a correction is +// held: written the hold short, it would clamp at the element's 0 (#1405). +for (const behavior of ['auto', 'smooth'] as const) { + test(`iOS hold (#1405): scrollToIndex(0) (${behavior}) after a tap reaches the top under a held correction`, () => { + withFakeIOSUserAgent(() => { + const { v, el, scrollToFn, scroll, touch } = makeIOSTouchVirtualizer({ + scrollTop: 200, + }) + // The element clamps a write to its range; a smooth one reports later. + scrollToFn.mockImplementation( + (offset: number, { adjustments = 0, behavior: b } = {}) => { + if (b !== 'smooth') el.scrollTop = Math.max(0, offset + adjustments) + }, + ) + touch('touchstart') + touch('touchend') // a tap: its tail holds the correction + v.resizeItem(0, 100) // above the viewport: held + expect(v['_holdOffset']).toBe(50) + + v.scrollToIndex(0, { align: 'start', behavior }) + // The hold is written first, where the reader is, then the command. + expect( + scrollToFn.mock.calls.map(([offset, opts]) => [ + offset + (opts.adjustments ?? 0), + opts.behavior, + ]), + ).toEqual([ + [250, undefined], + [0, behavior], + ]) + scroll(0, behavior === 'smooth') + scroll(0, false) + + expect(v['_holdOffset']).toBe(0) + expect(v.scrollOffset).toBe(0) + expect(v['getMeasurements']()[0]!.start - el.scrollTop).toBe(0) + expect(v.scrollState).not.toBeNull() + }) + }) +} + // A compensation write clamped by a not-yet-grown sizer is retried once the // sizer grows (#1258). That retry is a write like any other: it must wait // while a touch owns the scroll, and go out once the tail closes (#1327). From db995d7f220a075460d03684b5453841881cd487 Mon Sep 17 00:00:00 2001 From: Damian Pieczynski Date: Sun, 29 Nov 2026 14:21:22 +0100 Subject: [PATCH 2/5] fix(virtual-core): clamp a command to the element's max after writing the hold --- packages/virtual-core/src/index.ts | 5 ++ .../virtual-core/tests/ios-deferral.test.ts | 73 +++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/packages/virtual-core/src/index.ts b/packages/virtual-core/src/index.ts index 300ced557..8598bac27 100644 --- a/packages/virtual-core/src/index.ts +++ b/packages/virtual-core/src/index.ts @@ -2779,10 +2779,15 @@ export class Virtualizer< // looks like a scroll away from the target (#1405). Write the hold first // where a write is possible now (the command has closed a tap's tail), // as for the wheel above. Its clamp retry would write over the command. + // The target was clamped to a max that included the hold; a consumer + // that commits the sizer after the notify leaves the element its old + // max, so clamp it again, as for a command issued now. Reconcile + // retargets an index or end target once the sizer grows. if (offset < this._holdOffset && this._canWriteScroll()) { this.scrollState = null this._flushHoldIfReady(true) this._clampedAdjustment = null + offset = Math.min(offset, Math.max(this.getMaxScrollOffset(), 0)) } this.scrollState = { ...target, diff --git a/packages/virtual-core/tests/ios-deferral.test.ts b/packages/virtual-core/tests/ios-deferral.test.ts index f1697a2ee..1cd81313c 100644 --- a/packages/virtual-core/tests/ios-deferral.test.ts +++ b/packages/virtual-core/tests/ios-deferral.test.ts @@ -1732,6 +1732,79 @@ for (const behavior of ['auto', 'smooth'] as const) { }) } +// The same with a consumer that commits the sizer after the hold's notify +// (not inside `onChange`): the element keeps its old max for the command's +// write. 10 rows of 50, viewport 200, max 300; 4 rows above the viewport +// grow by 200 each, so the hold is 800 and row 3 starts at 750. +function lateSizerUnderHold() { + const h = makeDeferralHarness({ ios: true, start: 200 }) + const commit = () => { + h.el.scrollHeight = h.v.getTotalSize() + } + h.run(() => { + h.v.setOptions({ + ...h.v.options, + count: 10, + scrollToFn: (offset, { adjustments = 0 }) => { + h.writes.push(offset + adjustments) + h.el.scrollTop = Math.max( + 0, + Math.min(offset + adjustments, h.el.scrollHeight - h.el.clientHeight), + ) + }, + }) + h.v._willUpdate() + }) + commit() + h.run(() => h.scroll(false, 200)) + h.touch('touchstart') + h.touch('touchend') + h.run(() => h.scroll(true, 200)) + h.run(() => { + for (let i = 0; i < 4; i++) h.v.resizeItem(i, 250) + }) + expect(h.v['_holdOffset']).toBe(800) + h.writes.length = 0 + return { h, commit } +} + +test('iOS hold (#1405): scrollToIndex below the hold lands once a late sizer commits', () => { + const { h, commit } = lateSizerUnderHold() + h.run(() => h.v.scrollToIndex(3, { align: 'start' })) + // Written at the max the element has, not past it. + expect(h.writes).toEqual([1000, 300]) + h.run(() => h.scroll(false)) + commit() + h.run(() => { + for (let i = 0; i < 10; i++) { + h.advance(16) + h.frame() + h.scroll(false) + } + }) + expect(h.el.scrollTop).toBe(750) + expect(h.rowTop(3)).toBe(0) + expect(h.v.scrollState).toBeNull() +}) + +test('iOS hold (#1405): scrollToOffset below the hold ends at the max a late sizer leaves', () => { + const { h, commit } = lateSizerUnderHold() + h.run(() => h.v.scrollToOffset(760)) + expect(h.writes).toEqual([1000, 300]) + h.run(() => h.scroll(false)) + commit() + h.run(() => { + for (let i = 0; i < 10; i++) { + h.advance(16) + h.frame() + h.scroll(false) + } + }) + // As if issued after the flush: clamped to the max, and done. + expect(h.el.scrollTop).toBe(300) + expect(h.v.scrollState).toBeNull() +}) + // A compensation write clamped by a not-yet-grown sizer is retried once the // sizer grows (#1258). That retry is a write like any other: it must wait // while a touch owns the scroll, and go out once the tail closes (#1327). From 3a0826a5895db9cabadccb206583c92023cbab3b Mon Sep 17 00:00:00 2001 From: Damian Pieczynski Date: Sun, 29 Nov 2026 18:02:32 +0100 Subject: [PATCH 3/5] test: cover more commands below a held correction (#1405) Unit tests for scrollToOffset below the hold, a target equal to the hold, a negative hold, a finger still down and the iOS 27 queued fling. A Playwright spec runs the issue's tap-then-jump case with iOS emulation. --- .../app/test/ios-hold-below-target.spec.ts | 53 +++++++++ .../virtual-core/tests/ios-deferral.test.ts | 107 ++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 packages/react-virtual/e2e/app/test/ios-hold-below-target.spec.ts diff --git a/packages/react-virtual/e2e/app/test/ios-hold-below-target.spec.ts b/packages/react-virtual/e2e/app/test/ios-hold-below-target.spec.ts new file mode 100644 index 000000000..bba7c039a --- /dev/null +++ b/packages/react-virtual/e2e/app/test/ios-hold-below-target.spec.ts @@ -0,0 +1,53 @@ +import { expect, test } from '@playwright/test' + +// An iPhone UA plus touch emulation puts Chromium on the iOS code path (see +// ios-programmatic-landing.spec.ts). Only the hold bookkeeping is real here, +// not WebKit's touch physics. +test.use({ + hasTouch: true, + userAgent: + 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1', +}) + +// #1405: a tap opens the touch tail, a row above the viewport grows inside +// it (held), and the app jumps to the top. The target is less than the +// hold, so written the hold short it would clamp at 0 and the list would end +// the hold below the top. +for (const behavior of ['auto', 'smooth'] as const) { + test(`scrollToIndex(0) (${behavior}) after a tap reaches the top under a held correction`, async ({ + page, + browserName, + }) => { + test.skip(browserName !== 'chromium', 'touch emulation runs in Chromium') + // 50px rows, 400px viewport, at 1000: rows 15-19 are mounted above it. + await page.goto('/ios-deferral/?initialOffset=1000') + await expect + .poll(() => page.evaluate(() => (window as any).__t.el?.scrollTop)) + .toBe(1000) + + // All inside the page: the tail closes 150ms after the touchend. + const result = await page.evaluate(async (b) => { + const t = (window as any).__t + const touch = (type: string) => + t.el.dispatchEvent(new TouchEvent(type, { bubbles: true })) + touch('touchstart') + touch('touchend') + t.setH(17, 90, true) + for (let i = 0; i < 5 && t.v._holdOffset === 0; i++) await t.frames(1) + const hold = t.v._holdOffset + t.v.scrollToIndex(0, { align: 'start', behavior: b }) + for (let i = 0; i < 60 && t.el.scrollTop !== 0; i++) await t.frames(1) + await t.wait(300) + return { + hold, + top: t.el.scrollTop, + row0: t.rowTop(0), + holdAfter: t.v._holdOffset, + } + }, behavior) + + // The correction was held when the jump was made. + expect(result.hold).toBe(40) + expect(result).toEqual({ hold: 40, top: 0, row0: 0, holdAfter: 0 }) + }) +} diff --git a/packages/virtual-core/tests/ios-deferral.test.ts b/packages/virtual-core/tests/ios-deferral.test.ts index 1cd81313c..508a2ad9b 100644 --- a/packages/virtual-core/tests/ios-deferral.test.ts +++ b/packages/virtual-core/tests/ios-deferral.test.ts @@ -1732,6 +1732,113 @@ for (const behavior of ['auto', 'smooth'] as const) { }) } +// After a tap at 200 that grew row 0 by 50 (held), with an element that +// clamps writes to its range. +function tapHold50() { + const h = makeIOSTouchVirtualizer({ scrollTop: 200 }) + h.scrollToFn.mockImplementation( + (offset: number, { adjustments = 0, behavior } = {}) => { + if (behavior !== 'smooth') + h.el.scrollTop = Math.max(0, offset + adjustments) + }, + ) + h.touch('touchstart') + h.touch('touchend') + h.v.resizeItem(0, 100) + expect(h.v['_holdOffset']).toBe(50) + const writes = () => + h.scrollToFn.mock.calls.map( + ([offset, opts]) => offset + (opts.adjustments ?? 0), + ) + return { ...h, writes } +} + +for (const target of [0, 20, 49]) { + test(`iOS hold (#1405): scrollToOffset(${target}) below the hold lands`, () => { + withFakeIOSUserAgent(() => { + const { v, el, scroll, writes } = tapHold50() + v.scrollToOffset(target) + expect(writes()).toEqual([250, target]) + scroll(target, false) + expect(v['_holdOffset']).toBe(0) + expect(v.scrollOffset).toBe(target) + expect(el.scrollTop).toBe(target) + }) + }) +} + +test('iOS hold (#1405): a target equal to the hold keeps the old path', () => { + withFakeIOSUserAgent(() => { + const { v, writes } = tapHold50() + // Written the hold short: 50 - 50 = 0, which the element can take. + v.scrollToOffset(50) + expect(writes()).toEqual([0]) + expect(v['_holdOffset']).toBe(50) + }) +}) + +test('iOS hold (#1405): a negative hold keeps the old path', () => { + withFakeIOSUserAgent(() => { + const { v, scrollToFn, touch } = makeIOSTouchVirtualizer({ + scrollTop: 200, + }) + touch('touchstart') + touch('touchend') + v.resizeItem(0, 20) // above the viewport, shrinks: held + expect(v['_holdOffset']).toBe(-30) + v.scrollToIndex(0, { align: 'start' }) + // One write, the hold short (0 + 30); the hold is written later. + expect( + scrollToFn.mock.calls.map(([o, opts]) => o + (opts.adjustments ?? 0)), + ).toEqual([30]) + expect(v['_holdOffset']).toBe(-30) + }) +}) + +test('iOS hold (#1405): under a finger still down the hold is not written first', () => { + withFakeIOSUserAgent(() => { + const { v, scrollToFn, touch } = makeIOSTouchVirtualizer({ + scrollTop: 200, + }) + touch('touchstart') // the finger stays down: iOS ignores writes + v.resizeItem(0, 100) + expect(v['_holdOffset']).toBe(50) + v.scrollToIndex(0, { align: 'start' }) + // A known limit: written the hold short, as before. + expect( + scrollToFn.mock.calls.map(([o, opts]) => o + (opts.adjustments ?? 0)), + ).toEqual([-50]) + expect(v['_holdOffset']).toBe(50) + }) +}) + +test('iOS 27 hold (#1405): scrollToIndex(0) waiting for a fling lands when the tail closes', () => { + // A fling from 2000, now passing 1500, that grew row 0 by 50. + const h = makeDeferralHarness({ start: 2000, ios27: true }) + h.touch('touchstart') + h.run(() => h.scroll(true, 2010)) + h.touch('touchend') + h.run(() => h.scroll(true, 1500)) + h.run(() => h.v.resizeItem(0, 100)) + expect(h.v['_holdOffset']).toBe(50) + h.writes.length = 0 + + h.run(() => h.v.scrollToIndex(0, { align: 'start' })) + expect(h.writes).toEqual([]) + h.run(() => h.scroll(false)) + // The hold is written first, then the command, at the top. + h.expireTail() + expect(h.writes).toEqual([1550, 0]) + h.run(() => { + h.scroll(false, 0) + h.frame() + h.frame() + }) + expect(h.v['_holdOffset']).toBe(0) + expect(h.rowTop(0)).toBe(0) + expect(h.v.scrollState).toBeNull() +}) + // The same with a consumer that commits the sizer after the hold's notify // (not inside `onChange`): the element keeps its old max for the command's // write. 10 rows of 50, viewport 200, max 300; 4 rows above the viewport From 21eac66bc02f19d9704534136e8333c470694112 Mon Sep 17 00:00:00 2001 From: Damian Pieczynski Date: Sun, 29 Nov 2026 18:19:02 +0100 Subject: [PATCH 4/5] test: grow the row under a finger in the iOS hold spec On CI the hold was gone before the jump: the 150ms tap tail can close before the ResizeObserver reports. Grow the row with the finger down, which holds it as long as needed, then lift and jump in the same task. --- .../e2e/app/test/ios-hold-below-target.spec.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/react-virtual/e2e/app/test/ios-hold-below-target.spec.ts b/packages/react-virtual/e2e/app/test/ios-hold-below-target.spec.ts index bba7c039a..47683cd5a 100644 --- a/packages/react-virtual/e2e/app/test/ios-hold-below-target.spec.ts +++ b/packages/react-virtual/e2e/app/test/ios-hold-below-target.spec.ts @@ -9,8 +9,8 @@ test.use({ 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1', }) -// #1405: a tap opens the touch tail, a row above the viewport grows inside -// it (held), and the app jumps to the top. The target is less than the +// #1405: a row above the viewport grows during a tap (held), and the app +// jumps to the top from the tap's touchend. The target is less than the // hold, so written the hold short it would clamp at 0 and the list would end // the hold below the top. for (const behavior of ['auto', 'smooth'] as const) { @@ -25,16 +25,20 @@ for (const behavior of ['auto', 'smooth'] as const) { .poll(() => page.evaluate(() => (window as any).__t.el?.scrollTop)) .toBe(1000) - // All inside the page: the tail closes 150ms after the touchend. + // The row grows under a finger, which holds the correction for as long + // as it is down, so no timing matters until the lift. The tap's tail + // then lasts 150ms: the jump comes in the same task as the touchend. const result = await page.evaluate(async (b) => { const t = (window as any).__t const touch = (type: string) => t.el.dispatchEvent(new TouchEvent(type, { bubbles: true })) touch('touchstart') - touch('touchend') t.setH(17, 90, true) - for (let i = 0; i < 5 && t.v._holdOffset === 0; i++) await t.frames(1) + for (let i = 0; i < 120 && t.v._holdOffset === 0; i++) { + await t.frames(1) + } const hold = t.v._holdOffset + touch('touchend') t.v.scrollToIndex(0, { align: 'start', behavior: b }) for (let i = 0; i < 60 && t.el.scrollTop !== 0; i++) await t.frames(1) await t.wait(300) From 9eed68c7346a8baafecf50b237572e85401809c8 Mon Sep 17 00:00:00 2001 From: Damian Pieczynski Date: Sun, 29 Nov 2026 19:00:44 +0100 Subject: [PATCH 5/5] test: run _willUpdate after a late sizer commit in the #1405 tests As an adapter does. Without it the old clamp retry never got a chance to write over the command, so dropping the reset of _clampedAdjustment went unnoticed. --- packages/virtual-core/tests/ios-deferral.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/virtual-core/tests/ios-deferral.test.ts b/packages/virtual-core/tests/ios-deferral.test.ts index 508a2ad9b..f47d93d05 100644 --- a/packages/virtual-core/tests/ios-deferral.test.ts +++ b/packages/virtual-core/tests/ios-deferral.test.ts @@ -1845,8 +1845,10 @@ test('iOS 27 hold (#1405): scrollToIndex(0) waiting for a fling lands when the t // grow by 200 each, so the hold is 800 and row 3 starts at 750. function lateSizerUnderHold() { const h = makeDeferralHarness({ ios: true, start: 200 }) + // As an adapter does: the sizer commits, then `_willUpdate` runs. const commit = () => { h.el.scrollHeight = h.v.getTotalSize() + h.run(() => h.v._willUpdate()) } h.run(() => { h.v.setOptions({