Skip to content

feat(button): add native type#640

Open
lukasmatta wants to merge 1 commit into
masterfrom
637-allow-buttoncomponent-to-accept-a-configurable-type-prop
Open

feat(button): add native type#640
lukasmatta wants to merge 1 commit into
masterfrom
637-allow-buttoncomponent-to-accept-a-configurable-type-prop

Conversation

@lukasmatta
Copy link
Copy Markdown
Collaborator

@lukasmatta lukasmatta commented May 21, 2026

This pull request adds support for configuring the native HTML type attribute of the CpsButtonComponent, allowing it to be set to 'button', 'submit', or 'reset'. The default value is 'button'. The changes ensure that the new input is documented, properly reflected in the rendered HTML, and thoroughly tested.

Component API and Implementation:

  • Added a new @Input() nativeType property to CpsButtonComponent, defaulting to 'button', which controls the native HTML type attribute of the button (projects/cps-ui-kit/src/lib/components/cps-button/cps-button.component.ts).
  • Updated the template to bind the button's type attribute to the new nativeType input (projects/cps-ui-kit/src/lib/components/cps-button/cps-button.component.html).
  • Documented the new nativeType property in the component's JSON API data (projects/composition/src/app/api-data/cps-button.json).

Testing:

  • Added and updated unit tests to verify the default value of nativeType, its effect on the rendered button, and its independence from the styling type property (projects/cps-ui-kit/src/lib/components/cps-button/cps-button.component.spec.ts). [1] [2]

Release notes:

  • Add native type property for Button component

@lukasmatta lukasmatta self-assigned this May 21, 2026
Copilot AI review requested due to automatic review settings May 21, 2026 16:20
@lukasmatta lukasmatta requested a review from fateeand as a code owner May 21, 2026 16:20
@lukasmatta lukasmatta linked an issue May 21, 2026 that may be closed by this pull request
@github-actions
Copy link
Copy Markdown

Coverage report for library

St.
Category Percentage Covered / Total
🔴 Statements 42.44% 2887/6802
🔴 Branches 36.86% 1211/3285
🔴 Functions 41.13% 552/1342
🔴 Lines 43.16% 2704/6265

Test suite run success

875 tests passing in 31 suites.

Report generated by 🧪jest coverage report action from 300f67a

Copy link
Copy Markdown
Contributor

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

Adds a new nativeType input to CpsButtonComponent so consumers can configure the rendered HTML <button type="..."> (button|submit|reset), with a default of button, and documents/tests the behavior.

Changes:

  • Added nativeType: 'button' | 'submit' | 'reset' input to CpsButtonComponent (default: 'button').
  • Updated the button template to bind the native type attribute to nativeType.
  • Updated component API JSON and unit tests to cover the new input and ensure it doesn’t affect styling type.

Reviewed changes

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

File Description
projects/cps-ui-kit/src/lib/components/cps-button/cps-button.component.ts Introduces the nativeType input with a default value.
projects/cps-ui-kit/src/lib/components/cps-button/cps-button.component.html Binds the rendered <button> type attribute to nativeType.
projects/cps-ui-kit/src/lib/components/cps-button/cps-button.component.spec.ts Adds assertions/tests for default and configured nativeType values.
projects/composition/src/app/api-data/cps-button.json Documents nativeType in the generated component API data.

<div>
<button
type="button"
[attr.type]="nativeType"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

let's maybe apply this guard

Comment on lines +255 to +282
describe('nativeType', () => {
it('should default native type attribute to "button"', () => {
const button = fixture.nativeElement.querySelector('button');
expect(button.getAttribute('type')).toBe('button');
});

it('should set native type attribute to "submit"', () => {
fixture.componentRef.setInput('nativeType', 'submit');
fixture.detectChanges();
const button = fixture.nativeElement.querySelector('button');
expect(button.getAttribute('type')).toBe('submit');
});

it('should set native type attribute to "reset"', () => {
fixture.componentRef.setInput('nativeType', 'reset');
fixture.detectChanges();
const button = fixture.nativeElement.querySelector('button');
expect(button.getAttribute('type')).toBe('reset');
});

it('should not affect styling type when nativeType changes', () => {
fixture.componentRef.setInput('type', 'outlined');
fixture.componentRef.setInput('nativeType', 'submit');
fixture.detectChanges();
expect(component.classesList).toContain('cps-button--outlined');
const button = fixture.nativeElement.querySelector('button');
expect(button.getAttribute('type')).toBe('submit');
});
@github-actions
Copy link
Copy Markdown

Playwright test results

passed  70 passed

Details

stats  70 tests across 4 suites
duration  2 minutes, 12 seconds
commit  300f67a
info  For details, download the Playwright report

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.

Allow ButtonComponent to accept a configurable type prop

3 participants