mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-25 16:55:59 +03:00
[GH-ISSUE #4134] [bug]: Multiple collections/requests can be created on repeated Enter key presses from the create modal #1481
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#1481
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jamesgeorge007 on GitHub (Jun 20, 2024).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/4134
Originally assigned to: @xLansang on GitHub.
Is there an existing issue for this?
Current behavior
While creating collections/requests in a team workspace, repeatedly pressing the enter key while at the create collection modal will create multiple collections/requests. The click action on the button is disabled during the loading state, which should also be extended to the keypress action.
Steps to reproduce
+ Newfrom the collection panel to create a new root collection.This applies to creating folders/requests as demonstrated in the recording below.
https://github.com/hoppscotch/hoppscotch/assets/25279263/da9e3c38-5402-410c-9ffa-7413a99ade6f
Environment
Production
Version
Applicable to both Cloud & SH
@xLansang commented on GitHub (Oct 8, 2024):
Hello! i'd love to take this issue on. Please let me know if I can be assigned.
@SanskritiHarmukh commented on GitHub (Oct 9, 2024):
Hey @xLansang , Thank you for showing interest. Assigning the issue to you.
@xLansang commented on GitHub (Oct 10, 2024):
Sounds great, I'll keep you updated on my progress!
@ayushmatkar commented on GitHub (Oct 10, 2024):
Hii, I would love to work on this issue. Please let me know if it is to be assigned later anytime.
@xLansang commented on GitHub (Oct 17, 2024):
Hello @jamesgeorge007. my solution is to add these two lines in the primary.vue file in the ui repository. My understanding is that this file contains the implementation for the "HoppButtonPrimary" button. This is my first time coding in typescript, so I wanted to test if the implementation is correct. Please let me know if I am missing something or if this would possibly cause issues.

@jamesgeorge007 commented on GitHub (Oct 21, 2024):
Hi @xLansang, this issue arises in modals comprising an input element and a primary action button. There are two possibilities here where the primary action gets invoked multiple times via repeated
Enterkey presses:HoppSmartInputcomponent) is in focus where thesubmitevent is triggered.HoppButtonPrimarycomponent) is in focus where theclickevent is triggered.An ideal fix here accounting for the above cases is to prevent invoking the primary action for the second time if in the loading state.
Also, thanks for the PR. Given the above concern with the
HoppButtonPrimarycomponent, it's nice to handle things at the source. We'll evaluate and handle it appropriately in a later iteration.Given below are the possible scenarios where an early return needs to be added (A prop/local state variable indicating loading state is in scope):
github.com/hoppscotch/hoppscotch@9da5f63e70/packages/hoppscotch-common/src/components/collections/Add.vue (L9-L15)github.com/hoppscotch/hoppscotch@9da5f63e70/packages/hoppscotch-common/src/components/collections/Add.vue (L19-L24)github.com/hoppscotch/hoppscotch@9da5f63e70/packages/hoppscotch-common/src/components/collections/Add.vue (L71-L78)github.com/hoppscotch/hoppscotch@9da5f63e70/packages/hoppscotch-common/src/components/collections/AddFolder.vue (L71-L77)github.com/hoppscotch/hoppscotch@9da5f63e70/packages/hoppscotch-common/src/components/collections/AddRequest.vue (L168-L174)github.com/hoppscotch/hoppscotch@9da5f63e70/packages/hoppscotch-common/src/components/collections/Edit.vue (L70-L78)github.com/hoppscotch/hoppscotch@9da5f63e70/packages/hoppscotch-common/src/components/collections/EditFolder.vue (L71-L78)github.com/hoppscotch/hoppscotch@9da5f63e70/packages/hoppscotch-common/src/components/collections/EditRequest.vue (L156-L163)github.com/hoppscotch/hoppscotch@9da5f63e70/packages/hoppscotch-common/src/components/environments/teams/Details.vue (L354-L362)github.com/hoppscotch/hoppscotch@9da5f63e70/packages/hoppscotch-common/src/components/teams/Add.vue (L65-L66)Feel free to raise a PR accounting for the above cases :)
@xLansang commented on GitHub (Oct 21, 2024):
Hello @jamesgeorge007, thanks for the response! I see this approach handles both scenarios where either the smartInput or PrimaryButton is in focus. I'll raise a PR now accounting for the above cases using this approach.
@SanskritiHarmukh commented on GitHub (Oct 26, 2024):
Hey @jamesgeorge007 , is this issue completely resolved? Should we go ahead and close it?
@jamesgeorge007 commented on GitHub (Oct 27, 2024):
The PR has been merged and scheduled for the upcoming major release. I was thinking of closing the issue once the release is out, but we can go ahead and close this now.