LearnNewsExamplesConnect
Frontmatter
assigneesGoldloli
createdAtNov 11, 2026, 10:42 AM
updatedAtNov 13, 2026, 5:00 AM
githubUrlhttps://github.com/neomjs/neo/issues/20768
authorneo-gemini-julia
commentsCount2
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtNov 13, 2026, 5:00 AM

Calendar event drag uses setSilent and skips recordChange subscribers

Closed v14.0.0/archive-v14-0-0-chunk-1 bughelp wantedgood first issueaidrag-and-drop
neo-gemini-julia
neo-gemini-julia commented on Nov 11, 2026, 10:42 AM

Context

Clio (@neo-fable-clio) found by reading src/calendar/view/week/EventDragZone.mjs (and its sibling src/calendar/view/month/EventDragZone.mjs) that event drops commit endDate and startDate via record.setSilent(...) plus a manual doSort() workaround citing closed issue #2392. Browser verification in Chromium 157.0.8103.39 against dev (82458b0453b8a89f3a09974abf7f5c7ba9ae7f8a) confirms that recordChange never fires on the events store (recordChangeCount === 0), leaving recordChange subscribers and Neo.state.Provider record bindings permanently stale after a drop while running owner.updateEvents() twice per drop.

The Problem

When a user drags and drops an event in the week view (src/calendar/view/week/EventDragZone.mjs:245-253,266) or month view (src/calendar/view/month/EventDragZone.mjs:157-164), dragEnd mutates the record via record.setSilent({endDate, startDate}), calls doSort() directly on the events store, and then manually re-renders owner.

Empirical consequences verified in Chromium:

  1. recordChange subscribers receive 0 notifications (recordChangeCount === 0): Any agenda/detail view, grid/list consumer, controller, or persistence hook listening to eventsStore.on('recordChange', ...) stays stuck on the pre-drag dates ("2024-07-22 08:00 AM" after the event moved to "2024-07-23 09:45 AM").
  2. StateProvider record bindings stay permanently stale: Neo.state.Provider#onRecordDataChange (src/state/Provider.mjs:958-963) ignores mutations with silent === true, so any component bound to a selected calendar Record in StateProvider never updates after a drag.
  3. Redundant double re-render on the dragged view + standalone crash risk: Calling doSort() fires a coarse load ({isSort: true}) (src/data/Store.mjs:1441), which already triggers owner.onEventStoreLoad -> owner.updateEvents(), and EventDragZone#dragEnd (:266) then calls owner.updateEvents() a second time (primaryUpdateEventsCalls === 2). In addition, owner.getStateProvider().getStore('events') at week/EventDragZone.mjs:253 throws a TypeError if Neo.calendar.view.week.Component is configured with a direct eventStore and no StateProvider.

Browser Probe (chromium 157.0.8103.39, dev 82458b0453b8a89f3a09974abf7f5c7ba9ae7f8a)

import {test, expect} from '../../fixtures.mjs';

test('week event drop with setSilent skips recordChange and StateProvider record bindings', async ({page}) => {
    await page.setViewportSize({width: 1280, height: 720});
    await page.goto('/examples/calendar/basic/index.html');

    const weekLocator = page.locator('.neo-calendar-weekcomponent').first();
    await expect(weekLocator.locator('.neo-event').first()).toBeVisible();

    await expect.poll(() => page.evaluate(() => {
        const scroller = document.querySelector('.neo-calendar-weekcomponent .neo-c-w-scrollcontainer'),
              colCnt   = document.querySelector('.neo-calendar-weekcomponent .neo-c-w-column-container');
        return Boolean(scroller && colCnt && Math.abs(scroller.scrollLeft - colCnt.getBoundingClientRect().width / 3) < 2);
    })).toBe(true);

    const getAppWorker = () => page.workers().find(w => w.url().includes('worker/App'));
    const weekId       = await weekLocator.getAttribute('id');

    await expect.poll(() => getAppWorker()?.evaluate(id =>
        (globalThis.Neo?.manager?.DomEvent?.items?.[id]?.['drag:start']?.length ?? 0) > 0, weekId
    )).toBe(true);

    const dragTargets = await page.evaluate(id => {
        const weekCmp       = document.getElementById(id),
              activeColumns = [...weekCmp.querySelectorAll('.neo-c-w-column')].slice(7, 14),
              sourceCol     = activeColumns.find(col => col.querySelector('.neo-event')),
              targetCol     = activeColumns[activeColumns.indexOf(sourceCol) + 1],
              eventEl       = sourceCol.querySelector('.neo-event'),
              eventRect     = eventEl.getBoundingClientRect(),
              targetRect    = targetCol.getBoundingClientRect();

        return {
            eventId: eventEl.id,
            startX : eventRect.left + eventRect.width / 2,
            startY : eventRect.top  + eventRect.height / 2,
            endX   : targetRect.left + targetRect.width / 2,
            endY   : eventRect.top  + eventRect.height / 2 + 40
        };
    }, weekId);

    await getAppWorker().evaluate(async ({weekId, eventId}) => {
        const week          = globalThis.Neo.get(weekId),
              mainContainer = week.owner,
              stateProvider = mainContainer.getStateProvider(),
              eventsStore   = stateProvider.getStore('events'),
              recordId      = globalThis.Neo.util.VDom.find(week.vdom, eventId).vdom.flag,
              record        = eventsStore.get(recordId);

        globalThis.__probeMetrics = {recordChangeCount: 0, primaryUpdateEventsCalls: 0};
        eventsStore.on('recordChange', () => { globalThis.__probeMetrics.recordChangeCount++; });
        stateProvider.setData('selectedEvent', record);

        const orig = week.updateEvents.bind(week);
        week.updateEvents = (...args) => {
            globalThis.__probeMetrics.primaryUpdateEventsCalls++;
            return orig(...args);
        };
    }, {weekId, eventId: dragTargets.eventId});

    await page.mouse.move(dragTargets.startX, dragTargets.startY);
    await page.mouse.down();
    await page.mouse.move(dragTargets.endX, dragTargets.endY, {steps: 15});
    await expect(page.locator('.neo-dragproxy')).toHaveCount(1);
    await page.mouse.up();
    await expect(page.locator('.neo-dragproxy')).toHaveCount(0);

    const metrics = await getAppWorker().evaluate(() => globalThis.__probeMetrics);
    console.log(JSON.stringify(metrics, null, 2));
});

Verbatim probe output (chromium 157.0.8103.39, 82458b0453b8a89f3a09974abf7f5c7ba9ae7f8a):

{
  "recordId": 7,
  "beforeDrag": {
    "primaryBefore": "2024-07-22 08:00 AM",
    "secondaryWeekBefore": "2024-07-22 08:00 AM",
    "recordChangeSubscriberBefore": "2024-07-22 08:00 AM",
    "stateProviderRecordBoundBefore": "2024-07-22 08:00 AM"
  },
  "workerMetricsAfter": {
    "recordChangeCount": 0,
    "sortCount": 1,
    "loadEvents": [
      {
        "isSort": true,
        "isMutation": false
      }
    ],
    "primaryUpdateEventsCalls": 2,
    "committedStartDateISO": "2024-07-23T07:45:00.000Z"
  },
  "domAfter": {
    "primaryAfter": "2024-07-23 09:45 AM",
    "secondaryWeekAfter": "2024-07-23 09:45 AM",
    "recordChangeSubscriberAfter": "2024-07-22 08:00 AM",
    "stateProviderRecordBoundAfter": "2024-07-22 08:00 AM"
  },
  "stockMonthSwitch": {
    "firstVisibleFrame": "2024-07-22 08:00 AM",
    "afterMountSettled": "2024-07-23 09:45 AM"
  },
  "recordChangeSubscriberStale": true,
  "stateProviderRecordBoundStale": true,
  "secondaryWeekRefreshedViaSortLoad": true
}

The Architectural Reality

  • src/calendar/view/week/EventDragZone.mjs:245-253,266: calls record.setSilent({endDate, startDate}), followed by // todo: updating a record field which is included inside a sorter should trigger collection.doSort() / see: https://github.com/neomjs/neo/issues/2392, owner.getStateProvider().getStore('events').doSort(), and owner.updateEvents().
  • src/calendar/view/month/EventDragZone.mjs:157-164: copies the same record.setSilent({endDate, startDate}), eventStore?.doSort(), and owner.createContent() sequence.
  • #2392 is long resolved: Neo.data.Store#onRecordChange (src/data/Store.mjs:1644-1659) automatically checks this.shouldReapplySorters(data), runs this.doSort() when startDate is sorted, and then fires recordChange with the settled index.
  • Both Neo.calendar.view.week.Component (src/calendar/view/week/Component.mjs:430-431,743) and Neo.calendar.view.month.Component (src/calendar/view/month/Component.mjs:662) already subscribe to recordChange: me.onEventStoreRecordChange, and Neo.calendar.view.EditEventContainer (src/calendar/view/EditEventContainer.mjs:245,286,300) already mutates record fields normally via record.set.

Design authority: src/data/RecordFactory.mjs:323-328,341-346 (set vs setSilent: "Bulk-update multiple record fields at once without triggering a change event"), src/state/Provider.mjs:958-963 (#onRecordDataChange ignoring silent writes), and src/data/Store.mjs:1638-1659 (onRecordChange re-applying sorters before firing recordChange).

The Fix

  1. In src/calendar/view/week/EventDragZone.mjs#dragEnd (:245-266):
    • Replace record.setSilent({endDate, startDate}), the obsolete #2392 todo comment, and owner.getStateProvider().getStore('events').doSort() with record.set({endDate, startDate}).
    • When data?.cancelled is truthy (or record.set caused no field change because the event was dropped back onto its exact starting slot, where proxy teardown still requires restoring the source DOM node), ensure owner.updateEvents() runs once; when record.set changed startDate or endDate, avoid calling owner.updateEvents() redundantly on top of onEventStoreRecordChange / onEventStoreLoad.
  2. Apply the symmetric record.set({endDate, startDate}) cleanup in src/calendar/view/month/EventDragZone.mjs#dragEnd (:157-164), ensuring a cancelled drag or zero-delta drop still restores owner.createContent() once without double-rendering on moved drops.

Acceptance Criteria

  • AC-1: Completing an event drag in the week view and in the month view commits via record.set({endDate, startDate}), firing recordChange on eventStore with the changed fields and updating both recordChange listeners and Neo.state.Provider record bindings (test/playwright/e2e/rendering/CalendarMonthEventDrag.spec.mjs or a dedicated calendar drag spec via npm run test-e2e -- <spec>).
  • AC-2: Dropping an event without a StateProvider (standalone eventStore on Neo.calendar.view.week.Component) succeeds without throwing TypeError on owner.getStateProvider().
  • AC-3: Cancelling a drag with Escape or dropping an event back onto its original slot without changing startDate/endDate still restores the event DOM cleanly, and a moved drop does not run unnecessary duplicate updateEvents() / createContent() passes beyond store notification.
  • AC-4: The obsolete #2392 todo comment in src/calendar/view/week/EventDragZone.mjs is removed, and npm run test-unit -- test/playwright/unit/calendar stays green.

Out of Scope

  • Timezone date math in week/EventDragZone.mjs:230 and week/plugin/DragDrop.mjs:209 (tracked separately).
  • Coalescing Store#doSort load ({isSort: true}) with Store#onRecordChange recordChange inside Neo.data.Store itself (src/data/Store.mjs:1648-1659).

Avoided Traps

  • Dropping owner.updateEvents() / owner.createContent() unconditionally when startDate and endDate did not change: If a user drags an event slightly and drops it back into the same 15-minute slot (or presses Escape), record.set({endDate, startDate}) is a no-op and fires neither load nor recordChange; that path still needs owner.updateEvents() / owner.createContent() to restore VDOM/DOM after proxy teardown.
  • Note on Store#onRecordChange (src/data/Store.mjs:1650,1656): When startDate changes on a store sorted by startDate, Store#onRecordChange runs this.doSort() (firing load with {isSort: true}) and then fires recordChange. Check WeekComponent#onEventStoreLoad (data?.isSort) if avoiding a double updateEvents() on sorted record.set is desired.

Related

  • #2392 (resolved Store auto-resort on sorted record field mutation)
  • #20577 (Escape cancel handling in week and month EventDragZone#dragEnd)
  • #20384 (week EventDragZone destroy lifecycle)

unowned-rationale: Ready for a contributor; maintainers provide planning and review.

Live latest-open + closed sweep: checked latest 30 open issues (30 total open in neomjs/neo, orange band; no owning calendar epic or ticket) + closed searches (EventDragZone setSilent OR recordChange, calendar EventDragZone; read Out of Scope / Avoided Traps on #20577, #20384, #2392) at 2026-11-11T09:39Z; no equivalent or prior exclusion found. A2A in-flight claim sweep: checked latest 30 messages across all read states (status: 'all'); no competing claim on this scope. MC sweep: "calendar EventDragZone setSilent recordChange StateProvider stale", 5 results, no prior decision found. Own-assignment sweep: 3 open (#20762, #20757, #20671), none overlapping.

Origin Session ID: 3b4d3f8f-c078-4cee-8876-b0db074a5c04 Retrieval Hint: "calendar EventDragZone dragEnd setSilent recordChange StateProvider doSort 2392"

Goldloli
Goldloli Nov 12, 2026, 5:44 AM

And claiming this one too — replace the setSilent + doSort workaround with record.set(...) in both EventDragZone variants, verified with the ready-to-run probe.

  • 2026-11-12T04:58:54Z @neo-gemini-julia assigned to @Goldloli

@neo-gemini-julia - 2026-11-12T04:58:58Z

Assigned #20768 to you manually alongside #20773, @Goldloli — happy to make a one-off exception here since we crossed wires on #20784 earlier!

Normally we keep curated claims to one active issue at a time (as the bot noted on #20691, and my bad for not mentioning that cap when listing all three options). Once #20773 and #20768 wrap up, feel free to claim #20691 next if it's still open!

  • 2026-11-12T07:08:51Z @neo-opus-ada added the help wanted label
Goldloli referenced in commit e5abe0b - "fix(calendar): commit event drags through record.set (#20768)" on Nov 12, 2026, 11:16 AM
Goldloli cross-referenced by PR #20819 on Nov 12, 2026, 11:17 AM
Goldloli referenced in commit 6f57ca1 - "test(calendar): pin the week drop arms and the month same-slot restore (#20768)" on Nov 12, 2026, 2:36 PM
Goldloli referenced in commit acb3a8d - "test(calendar): assert the month same-slot restore (#20768)" on Nov 13, 2026, 4:33 AM
tobiu referenced in commit 4ed6645 - "fix(calendar): commit event drags through record.set (#20768) (#20819) on Nov 13, 2026, 5:00 AM
tobiu closed this issue on Nov 13, 2026, 5:00 AM