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

Add <LoadingIndicator onClick> prop, allowing to trigger actions (like a refresh) on click #9420

Merged
merged 2 commits into from
Nov 7, 2023

Conversation

david-bezero
Copy link
Contributor

As requested in #9418

This makes it possible to invoke a callback when a user clicks the LoadingIndicator to trigger a refresh, primarily to address this use-case: #3617 (comment)

I didn't find any existing unit tests for this part of the code, but I'm happy to add a unit test if somebody can point me to where it should go.

@fzaninotto
Copy link
Member

That's indeed a very minor change that we can merge. Yet it's a new feature, so you should PR against next instead of master.

Also, TypeScript complains.

@david-bezero
Copy link
Contributor Author

david-bezero commented Nov 7, 2023

I have fixed the types and updated to point to next.

To avoid going out-of-sync in the future, I'm just forwarding the type from RefreshIconButtonProps (technically the type it expects is ((e: MouseEvent) => void) & MouseEventHandler<HTMLButtonElement>, which looks like a mistake — it should probably be MouseEventHandler<HTMLButtonElement> — but that's a separate issue in RefreshIconButton)

I followed the existing pattern for merging props from RefreshIconButton.

Copy link
Contributor

@slax57 slax57 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@slax57 slax57 changed the title Pass onClick to RefreshIconButton from LoadingIndicator Add onClick prop to <LoadingIndicator>, allowing to trigger actions (like a refresh) on click Nov 7, 2023
@fzaninotto fzaninotto merged commit c5fdd87 into marmelab:next Nov 7, 2023
8 checks passed
@fzaninotto
Copy link
Member

Thanks!

@fzaninotto fzaninotto added this to the 4.16.0 milestone Nov 7, 2023
@david-bezero david-bezero deleted the loading-indicator-on-click branch November 7, 2023 16:17
@fzaninotto fzaninotto changed the title Add onClick prop to <LoadingIndicator>, allowing to trigger actions (like a refresh) on click Add <LoadingIndicator onClick> prop, allowing to trigger actions (like a refresh) on click Nov 10, 2023
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.

3 participants