-
Notifications
You must be signed in to change notification settings - Fork 7
Prevent unintentional form submission in button components #1087
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
Merged
jvictordev1
merged 4 commits into
main
from
hotfix/prevent-unintentional-form-submit-16634732863355235093
May 20, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a2ab81f
fix: prevent unintentional form submission in button components
google-labs-jules[bot] 4d31eaf
docs: update component metadata and acknowledge PR comment
google-labs-jules[bot] b56ffbe
refactor: corrige comentarios
8ebc33e
Merge branch 'main' of https://github.com/Sysvale/cuida into hotfix/p…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,6 +81,7 @@ | |
| </div> | ||
|
|
||
| <button | ||
| type="button" | ||
| class="mobile-navigation__sidebar-logout" | ||
| @click="emit('logout')" | ||
| > | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { describe, test, expect } from 'vitest'; | ||
| import SegmentedControl from '../components/SegmentedControl.vue'; | ||
| import { mount } from '@vue/test-utils'; | ||
|
|
||
| describe('SegmentedControl', () => { | ||
| test('renders correctly', async () => { | ||
| const wrapper = mount(SegmentedControl, { | ||
| props: { | ||
| segments: ['Segment 1', 'Segment 2'], | ||
| }, | ||
| }); | ||
|
|
||
| expect(wrapper.html()).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test('should have type="button" in all segment buttons to prevent form submission', () => { | ||
| const wrapper = mount(SegmentedControl, { | ||
| props: { | ||
| segments: ['Segment 1', 'Segment 2'], | ||
| }, | ||
| }); | ||
|
|
||
| const buttons = wrapper.findAll('button'); | ||
| buttons.forEach((button) => { | ||
| expect(button.attributes('type')).toBe('button'); | ||
| }); | ||
| }); | ||
|
|
||
| test('should NOT trigger form submit when a segment is clicked', async () => { | ||
| const TestComponent = { | ||
| components: { SegmentedControl }, | ||
| template: ` | ||
| <form @submit.prevent="handleSubmit"> | ||
| <SegmentedControl :segments="['S1', 'S2']" /> | ||
| </form> | ||
| `, | ||
| data() { | ||
| return { submitted: false }; | ||
| }, | ||
| methods: { | ||
| handleSubmit() { | ||
| this.submitted = true; | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| const wrapper = mount(TestComponent); | ||
| const button = wrapper.find('button'); | ||
|
|
||
| await button.trigger('click'); | ||
|
|
||
| expect(wrapper.vm.submitted).toBe(false); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
|
||
| exports[`IconButton > renders correctly 1`] = `"<span data-v-f6045c74="" id="CdsIcon-button"><span data-v-f6045c74=""><button data-v-f6045c74="" class="CdsIcon-button__container CdsIcon-button--lg CdsIcon-button__container--white"><cds-icon-stub data-v-f6045c74="" name="trash-outline" width="24" height="24" color="currentColor" dark="false" light="false" class="CdsIcon-button__icon"></cds-icon-stub></button></span></span>"`; | ||
| exports[`IconButton > renders correctly 1`] = `"<span data-v-f6045c74="" id="CdsIcon-button"><span data-v-f6045c74=""><button data-v-f6045c74="" type="button" class="CdsIcon-button__container CdsIcon-button--lg CdsIcon-button__container--white"><cds-icon-stub data-v-f6045c74="" name="trash-outline" width="24" height="24" color="currentColor" dark="false" light="false" class="CdsIcon-button__icon"></cds-icon-stub></button></span></span>"`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
|
||
| exports[`SegmentedControl > renders correctly 1`] = `"<div class="segment-control"><button type="button" class="segment-control__button segment-control__button--inactive"><span>Segment 1</span></button><button type="button" class="segment-control__button segment-control__button--inactive"><span>Segment 2</span></button></div>"`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.