Prefetch component props forms

Created on 26 August 2024, 4 months ago
Updated 27 August 2024, 4 months ago

Overview

Rendered component props forms are fetched from the API when components are clicked in the preview. Our usage of Redux Toolkit Query (see ui/src/services/components.ts) ensures that responses are cached, so no request is made twice for the same component when it is clicked again.

See gif in Merge request !178 that illustrates the component props form.

Idea from @Wim Leers in Improve (or remove!) loading state when selecting components Closed: outdated :

[...] why not pre-emptively fetch all component props forms? 🤔 Or, better yet: the component props forms for the component instances that are visible in the viewport? 🤓

Proposed resolution

Use Redux Toolkit Query's prefetching feature.

User interface changes

With active prefetching, the spinner element wrapping the component props form will almost never be visible. There can still be instances when we don't have prefetched data, e.g. intermittent network failures, so we should't remove the spinner. The code is already written, so the spinner is not shown if cached data is used by Redux Toolkit Query.

Feature request
Status

Active

Component

Page builder

Created by

🇳🇱Netherlands balintbrews Amsterdam, NL

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

Sign in to follow issues

Comments & Activities

  • Issue created by @balintbrews
  • 🇳🇱Netherlands balintbrews Amsterdam, NL
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    🤩

  • 🇮🇳India soaratul

    I am concerned for a page having too many components, in that case all the component's props data would get stored into redux cache after fetching them - so for too many components there would be too many api calls on page load itself, that might slow down the performance of the page.

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    so for too many components there would be too many api calls on page load itself, that might slow down the performance of the page.

    That's a fair point!

    It could indeed easily happen that >100 components are in use, at which point that's 100 requests and … a lot of form state being generated on the server side too.

    I think that means this should be closed. @balintbrews, do you agree?

Production build 0.71.5 2024