Skip to content

[Bug] List: every list bundles the animatedLayout row glide, 11.4 kB gzipped #11608

Open

Description

@duytbp

Description

Every page that renders a List (and so every CheckboxList, which renders one) bundles List's row layout animation, though only a List given animatedLayout ever runs it. List.tsx imports useListLayoutUpdates from ./listLayoutUpdates statically (L43) and calls it on every render (L359); without the handle the hook returns early. ListItem.tsx also imports isReportedRow and keepPresentation from the same module (L61). listLayoutUpdates in turn imports motion/animatedLayout (playLayoutChange, holdLayoutExit, reportLayoutChange, landLayoutGlideSideways), so the whole glide machinery comes with any list: 11.4 kB of JavaScript gzipped on a page with one CheckboxList.

It came with List's animatedLayout (#8106, 0.7.12).

Expected: a page whose lists don't take animatedLayout doesn't load the layout-update modules. Actual: it loads all of them.

Reproduction

A Vite 8.3.8 production build with React 19.3.1 and @astryxdesign/core 0.7.15, of this entry alone:

import { createElement as h, useState } from 'react';
import { createRoot } from 'react-dom/client';
import { CheckboxList, CheckboxListItem } from '@astryxdesign/core/CheckboxList';

function App() {
  const [value, setValue] = useState(['email']);
  return h(CheckboxList, { label: 'Notify me by', value, onChange: setValue },
    h(CheckboxListItem, { label: 'Email', value: 'email' }),
    h(CheckboxListItem, { label: 'SMS', value: 'sms' }),
    h(CheckboxListItem, { label: 'Push', value: 'push' }),
  );
}

createRoot(document.getElementById('root')).render(h(App));

Then the same build with one change: a resolver plugin swaps ./listLayoutUpdates.js, when List/List.js or List/ListItem.js imports it, for a stub with the same exports:

const noop = () => {};
export function useListLayoutUpdates() { return noop; }
export function isReportedRow() { return false; }
export function keepPresentation() {}

In Chromium both builds render the three checkboxes, toggle them, and log no errors.

Build JS loaded up front, gzip level 9
React and react-dom alone (<p>Hello</p>) 67.5 kB
One CheckboxList 151.1 kB
The same, listLayoutUpdates stubbed 139.7 kB

The stub removes five modules from the build: List/listLayoutUpdates, motion/animatedLayout, motion/presentation, privateAttributes/leaving.stylex and privateAttributes/reducedMotion.stylex.

Still the same on main (96ea823): the imports at List.tsx L43 and ListItem.tsx L61 are unchanged.

Possible directions: an app that passes animatedLayout has already imported useAnimatedLayout, so the handle could carry the row reporter and List would call it only when the handle is set; or List could load listLayoutUpdates with a dynamic import() the first time it gets a handle. isReportedRow and keepPresentation only read the shared reported-rows map, so they could live in a small module of their own that ListItem imports. The same pattern as #11570 (Button's tooltip layer) and #11569 (Table's cell context menu).

Astryx Version

0.7.15 (also main 96ea823)

Environment

Any browser; a bundle-size issue. Measured with Vite 8.3.8 (Rolldown), React 19.3.1, Node, Linux; module list from the build's source maps; render checked in headless Chromium (Playwright 1.64).

Activity

  1. cixzhang commented on Nov 14, 2026

    @cixzhang
    Contributor

    (Posted by Cindy's agent.)

    Thanks for the clear report and the Vite repro. The fix is in #11635 (draft, in review). useAnimatedLayout's handle now carries the four layout calls a List makes, and List reads them from the handle it is given. A List without a handle, and so every CheckboxList, no longer loads the row layout animation. Measured on app pages:

    • a List page goes from about 70.7 KB to 39.2 KB minified (25.7 KB to 14.7 KB gzip);
    • a CheckboxList form page goes from 230.6 KB to 203.1 KB (78.2 KB to 68.3 KB gzip).

    Lists given a handle animate their rows as before. We'll post again here when it ships.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions