Skip to content
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

fix: loading on ion button with dropdown #1189

Merged
merged 2 commits into from
Nov 12, 2024
Merged
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: 1 addition & 1 deletion projects/ion/src/lib/button/button.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class="icon"
></ion-icon>
<ion-icon
*ngIf="options && !circularButton"
*ngIf="options && !circularButton && !loading"
[type]="showDropdown ? 'semi-up' : 'semi-down'"
[size]="iconSize"
class="icon"
Expand Down
4 changes: 4 additions & 0 deletions projects/ion/src/lib/button/button.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ button {

.right-side-icon {
flex-direction: row-reverse;

.spinner {
margin-right: 0;
}
}

.ion-remove-space {
Expand Down
16 changes: 16 additions & 0 deletions projects/ion/src/lib/button/button.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,22 @@ describe('ButtonComponent with dropdown', () => {
userEvent.type(screen.getByTestId('input-element'), typeText);
expect(searchEvent).toHaveBeenLastCalledWith(typeText);
});

it('should not render the dropdown arrow when loading', async () => {
const options = [{ label: 'Option 1' }, { label: 'Option 2' }];

await sut({
label: defaultName,
loading: true,
options,
});

const arrowDownIcon = document.getElementById('ion-icon-semi-down');
const arrowUpIcon = document.getElementById('ion-icon-semi-up');

expect(arrowDownIcon).not.toBeInTheDocument();
expect(arrowUpIcon).not.toBeInTheDocument();
});
});

it('should close dropdown when click outside component', async () => {
Expand Down
13 changes: 13 additions & 0 deletions stories/Button.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,19 @@ O Ion, Suporta 4 tamanhos padrões para botões. Basta configurar a propriedade
}}
secondary
</Story>
<Story
name="with dropdown: loading"
decorators={[
moduleMetadata({
imports: [CommonModule, IonSharedModule],
}),
]}
>
{{
template: `<ion-button label="Primary" rightSideIcon="true" loading="true" [options]="[{ label: 'option 1' }, {label: 'option 2'}]"></ion-button>`,
}}
secondary
</Story>
</Canvas>

- `enableSearch`. Adiciona um campo de busca no dropdown para realizar uma busca nas opções.
Expand Down
Loading