-
Notifications
You must be signed in to change notification settings - Fork 0
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
Button: prevent double-click & add loader #802
base: main
Are you sure you want to change the base?
Conversation
Why: Nudge developers to consider using a loading component & preventing users' double/multi-clicks
Realized we have 2 additional Button components where the difference between the 3 lies in the stylesheets only. Debating with myself whether to have a base class (plenty of cons) vs merging the stylesheets in order to not repeat too much code... Ideally the components are 100% self-contained when downloaded from the library, and we might actually just be better off with repeated logic. (No hook, extendable ButtonBase component or HOC) |
I think this is a really useful addition. At the same time I am however not so happy that it adds internal state to our otherwise very simplistic button component. I wonder if it would be a feasible solution to instead have a wrapper component that implements the loading functionality, e.g.: <LoadWhileClicked loadingText="Loading...">
<Button>Testing</Button>
</LoadWhileClicked> I believe it should be possible to have |
logic prevents double-click & shows "Loading..."
4dc7144
to
f04e155
Compare
Interesting idea, I will give it a shot later today💡 |
The idea of a wrapper component that displays loading... text or a loading animation & hides existing content seems redundant to create if only paired with the Button, so I attempted to make it more generic. (ex to fit Dropdown, Select & Input) It's proving nontrivial to me to ensure that content within a generic child component is not shown, while a custom loading text or icon replaces said content, positioned in the middle of the child element. I will leave this PR as is for now, unless we come up with other ideas. |
Pet peeves of mine:
<button />
onClick can be called twice by default<button />
changing width/height when showing a loading text/componentThis PR is intended to solve above points by:
isLoading
state in the Button componentChanged .eslintrc to allow console.log statements