Skip to content

feat: add standalone content display preference component#4805

Draft
ernst-dev wants to merge 1 commit into
mainfrom
feat/standalone-content-display-preference
Draft

feat: add standalone content display preference component#4805
ernst-dev wants to merge 1 commit into
mainfrom
feat/standalone-content-display-preference

Conversation

@ernst-dev

Copy link
Copy Markdown
Member

Description

Exposes the content-display preference control (drag-and-drop column reordering + visibility toggles, optional column filtering and grouping) as a standalone ContentDisplayPreference component, usable outside the CollectionPreferences modal.

Unlike CollectionPreferences, the standalone component is fully controlled and emits an onChange event immediately on every reorder/toggle (no confirm step). This lets consumers react to selection before submission — e.g. enforce a maximum number of visible columns, which is the motivating use case in the linked request.

The implementation reuses the existing internal content-display renderer (src/collection-preferences/content-display) rather than duplicating it. CollectionPreferences continues to render the same shared core unchanged, so its behavior and public API are unaffected.

Changes:

  • New public component src/content-display-preference/ (index.tsx, internal.tsx, interfaces.ts, styles.scss). ContentDisplayPreferenceProps reuses the shared content-display item/option/i18n types from CollectionPreferencesProps to stay in sync.
  • Test-utils DOM wrapper (src/test-utils/dom/content-display-preference) extending the existing content-display wrapper.
  • Pluralization entry for the new component name (build-tools/utils/pluralize.js).
  • Unit tests and a dev page (pages/content-display-preference/simple.page.tsx) demonstrating the "max visible columns" reactive use case.

Related links, issue #, if available: AWSUI-60078

How has this been tested?

  • npm run quick-build — green.
  • eslint + stylelint on the new/changed files — green.
  • New unit tests (13, incl. rendering, immediate onChange on toggle & keyboard reorder, alwaysVisible, column filtering, groups, and base-component API) — all pass.
  • Existing collection-preferences/content-display unit tests (56) — still pass (shared core untouched).
Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant