Skip to content

feat(button): added possibility to set commandfor and command attributes #4408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mfranzke
Copy link
Collaborator

Proposed changes

Enables implementation of #3322

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (fix on existing components or architectural decisions)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Further comments

@mfranzke mfranzke self-assigned this Jun 24, 2025
@mfranzke mfranzke requested a review from nmerget as a code owner June 24, 2025 20:36
@mfranzke mfranzke added the 🍄🆙improvement New feature or request label Jun 24, 2025
Copy link
Contributor

@mfranzke mfranzke moved this to 👀 In review in UX Engineering Team Backlog Jun 24, 2025
nmerget
nmerget previously approved these changes Jun 25, 2025
@nmerget nmerget enabled auto-merge (squash) June 26, 2025 07:42
@mfranzke mfranzke moved this from 👀 In review to 🏗 In development in UX Engineering Team Backlog Jun 26, 2025
@nmerget nmerget self-requested a review June 26, 2025 10:08
@nmerget
Copy link
Collaborator

nmerget commented Jun 26, 2025

The React types aren't ready for this feature. We need to add a custom interface IntrinsicElements to add it for react.

Is there any community member asking for this feature?

@nmerget nmerget marked this pull request as draft June 26, 2025 10:12
auto-merge was automatically disabled June 26, 2025 10:12

Pull request was converted to draft

@mfranzke
Copy link
Collaborator Author

The React types aren't ready for this feature. We need to add a custom interface IntrinsicElements to add it for react.

Is there any community member asking for this feature?

React doesn't seem to react on this:

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds support for the HTML commandfor and command attributes to the button component, enabling implementation of command button functionality. These attributes allow buttons to control other interactive elements on the page.

  • Added commandfor and command properties to the button component type definitions
  • Updated the button component template to render the new attributes

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/components/src/components/button/model.ts Added type definitions for commandfor and command properties with documentation
packages/components/src/components/button/button.lite.tsx Added rendering of commandfor and command attributes to the button element

@@ -79,6 +79,16 @@ export type DBButtonDefaultProps = {
* Variant of the button. Use only 1 primary button on a page as CTA otherwise use one of the adaptive buttons.
*/
variant?: ButtonVariantType | string;

/**
* Either standardized or custom actions to be performed on an element that is being controlled by a control <button>, specified via the commandfor attribute. (https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#commandfor)
Copy link
Preview

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation comment appears to be incomplete or unclear. The phrase 'Either standardized or custom actions to be performed on an element that is being controlled by a control ' is confusing. Consider clarifying that this attribute specifies the ID of the element to be controlled.

Suggested change
* Either standardized or custom actions to be performed on an element that is being controlled by a control <button>, specified via the commandfor attribute. (https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#commandfor)
* Specifies the ID of the element to be controlled by the button. This attribute is used to associate the button with an interactive element that it controls. (https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#commandfor)

Copilot uses AI. Check for mistakes.

commandfor?: string;

/**
* Turns a <button> HTML element into a command button, controlling the given interactive element; takes the ID of the element to control as its value. (https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#command)
Copy link
Preview

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation describes the command attribute functionality, but based on the MDN link and HTML specification, this attribute description may be inaccurate. The command attribute typically specifies the command to execute, not the ID of an element to control. Please verify the attribute behavior and update the documentation accordingly.

Suggested change
* Turns a <button> HTML element into a command button, controlling the given interactive element; takes the ID of the element to control as its value. (https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#command)
* Specifies a command to execute, typically used in <command> elements. Note that the `command` attribute is not standard for <button> elements and may not be widely supported. (https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/command)

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍄🆙improvement New feature or request
Projects
Status: 🏗 In development
Development

Successfully merging this pull request may close these issues.

2 participants