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
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/components/src/components/button/button.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export default function DBButton(props: DBButtonProps) {
value={props.value}
aria-describedby={props.describedbyid}
aria-expanded={props.ariaexpanded}
commandfor={props.commandfor}
command={props.command}
aria-pressed={props.ariapressed}>
<Show when={props.text} else={props.children}>
{props.text}
Expand Down
10 changes: 10 additions & 0 deletions packages/components/src/components/button/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

*/
command?: string;
};

export type DBButtonProps = DBButtonDefaultProps &
Expand Down
Loading