feat: add Invoker Commands (command/commandfor) to dialog-based components#6513
Conversation
🦋 Changeset detectedLatest commit: f1fe821 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Agent-Logs-Url: https://github.com/db-ux-design-system/core-web/sessions/9f347c3d-ad28-49b3-8d49-3eb46a67bc9b Co-authored-by: mfranzke <787658+mfranzke@users.noreply.github.com>
…nents Add command and commandfor HTML attributes to buttons interacting with dialog elements in the drawer and header components. Include feature detection fallback for older browsers. Update plain HTML examples and documentation to showcase Invoker Commands usage. Agent-Logs-Url: https://github.com/db-ux-design-system/core-web/sessions/9f347c3d-ad28-49b3-8d49-3eb46a67bc9b Co-authored-by: mfranzke <787658+mfranzke@users.noreply.github.com>
Add React post-build script to generate type declarations for the command and commandfor HTML attributes. Add changeset for the new Invoker Commands feature. Agent-Logs-Url: https://github.com/db-ux-design-system/core-web/sessions/9f347c3d-ad28-49b3-8d49-3eb46a67bc9b Co-authored-by: mfranzke <787658+mfranzke@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces the web platform’s Invoker Commands API (command / commandfor) across dialog-based components (Drawer/Header) and related documentation, plus build-pipeline adjustments to avoid attribute mangling and support React typings.
Changes:
- Add
command/commandforprops toDBButtonand pass them through to the native<button>. - Wire Invoker Commands into
DBDrawerandDBHeader(and update plain-HTML docs/examples with a JS fallback for unsupported browsers). - Update build scripts: Stencil
for={→htmlFor={replacement avoids touchingcommandfor, and React post-build generates a type augmentation file.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/foundations/docs/BrowserSupport.md | Marks Invoker Commands as actively used (not planned). |
| packages/components/src/components/button/model.ts | Adds command / commandfor to the public Button prop model. |
| packages/components/src/components/button/button.lite.tsx | Passes command / commandfor through to the native <button>. |
| packages/components/src/components/drawer/drawer.lite.tsx | Adds command listener + close button Invoker Commands attributes. |
| packages/components/src/components/drawer/index.html | Updates example to use Invoker Commands + JS fallback. |
| packages/components/src/components/drawer/docs/HTML.md | Documents Invoker Commands usage + JS fallback snippet. |
| packages/components/src/components/header/header.lite.tsx | Adds derived drawer id + burger-menu Invoker Commands attributes. |
| packages/components/src/components/header/docs/HTML.md | Documents Invoker Commands usage + JS fallback snippet. |
| packages/components/scripts/post-build/stencil.ts | Regex replacement prevents commandfor from being altered. |
| packages/components/scripts/post-build/react.ts | Writes a React type augmentation file for command / commandfor. |
| package-lock.json | Lockfile changes (includes Vue patch/range updates). |
| .changeset/invoker-commands-dialog.md | Declares a minor bump for affected packages. |
- Fix event listener leak: use AbortController + onUnMount to clean up the command event listener when drawer is unmounted - Fix header drawer ID: derive from props.id ?? props.propOverrides?.id so commandfor works when id is set via propOverrides - Fix React type augmentation: change .d.ts to .ts and import from index.ts so it's included in the compiled dist/ output - Update TODO comment in React post-build per suggestion - Update feature detection text in drawer and header HTML docs with polyfill reference per suggestions Agent-Logs-Url: https://github.com/db-ux-design-system/core-web/sessions/f2040173-be93-4267-84d0-0ba10910dfec Co-authored-by: mfranzke <787658+mfranzke@users.noreply.github.com>
even in the other files
even in the other files
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
We should just add |
…pilot/add-invoker-commands-to-dialog-components
command/commandfor) to dialog-based components
| export type DBHeaderProps = DBHeaderDefaultProps & | ||
| InnerCloseButtonProps & | ||
| GlobalProps & | ||
| ToggleEventProps & | ||
| ContainerWidthProps; |
| command="close" | ||
| commandfor={props.id ?? props.propOverrides?.id} | ||
| onClick={(event) => state.handleClose(event, true)}> |
| command="show-modal" | ||
| commandfor={`${props.id ?? props.propOverrides?.id ?? state.generatedId}-drawer`}> |
| closeDialog: () => { | ||
| if (_ref?.open) { | ||
| if (dialogContainerRef) { |
Integrate the Invoker Commands API (
commandandcommandforHTML attributes) into all components using<dialog>, with JavaScript feature detection for older browsers.follow up to #6603
DBDrawer
command="close"+commandforpointing to the dialog'sidcommandevent listener on<dialog>callspreventDefault()to preserve animation and JS state managementDBHeader
command="show-modal"+commandforpointing to derived drawer ID (${id}-drawer)idderived from the header'sidpropPlain HTML examples & docs
BrowserSupport.md
Original prompt
🔭🐙🐈 Test this branch here: https://design-system.deutschebahn.com/core-web/review/copilot/add-invoker-commands-to-dialog-components