Repository navigation
Fix create view modal submitting the request twice - #20552
Open
SomSamantray wants to merge 1 commit into
Open
SomSamantray wants to merge 1 commit into
SomSamantray wants to merge 1 commit into
Conversation
Each time the create view dialog was opened, handleCreateViewModal() bound a new click handler to #createViewModalGoButton. That button is in the modal footer, which is rendered once per page and not replaced on each open, so after a second open a single click on Go posted the create request twice. Unbind the previous handler before binding the new one, and add a regression test that opens the modal twice and expects one request. Fixes phpmyadmin#18104 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Signed-off-by: Som Samantray <som.samantray@meritto.com>
Contributor
|
@MauricioFauth Can't we just have delegated events and not worry about the |
Author
I kept the
Delegated events would fix the same bug. If you prefer that style, I can switch: bind |
Contributor
|
Submitting Claude generated fixes is ok, but please don't reply with Claude generated text to humans. Reading Claude's text is so nauseating. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Each time the create view dialog was opened,
handleCreateViewModal()attached another click handler to#createViewModalGoButton. That button sits in the modal footer, which is rendered once per page and not replaced on each open. After the dialog had been opened a second time, one click on Go posted the create-view request twice.This change removes the previous handler before binding a new one, so each submit sends one request.
Fixes #18104
Root cause:
resources/js/modules/functions/handleCreateViewModal.tsbinds to the static button on every open. The button is defined inresources/templates/modals/create_view.twig.Known limitation, not changed here: two clicks on Go within a single open still each send a request, because the button is not disabled while a request is in flight. The issue's expected behaviour covers consecutive submissions across opens.
Testing
tests/javascript/modules/functions/handleCreateViewModal.test.ts. It opens the modal twice, clicks Go once, and expects one request toindex.php?route=/view/create. On the original code it records two requests; with this change it records one.npx jest: 4 suites, 6 tests pass.eslint resources/js tests/javascript jest.config.cjs: clean.Checklist
master. The bug is in the unreleased 6.0 line, and noQA_6_0branch exists yet.Signed-off-byline (DCO).AI assistance
This pull request was prepared with AI assistance (Claude Code, Claude Haiku 5.5). The author reviewed the diff and ran the tests listed above. CONTRIBUTING.md and the repository contain no AI contribution policy that applies to this change.
🤖 Generated with Claude Code