aminghadersohi opened a new pull request, #45336: URL: https://github.com/apache/superset/pull/45336
### SUMMARY The SQL Lab Run/Stop button is a single element whose label and click handler switch with the query state. The browser fires `click` on release, so a press that began while the button showed **Stop** and was released after the query finished was dispatched as a **Run** click and executed the SQL again. In acceptance testing a pointer gesture started on Stop produced two execute requests, zero stop requests, and a 1,000-row `INSERT` writing 2,000 rows; a CTAS run clicked near completion re-ran and failed with "relation already exists". This change records the action the button showed when the pointer or key gesture started (`pointerdown`, or a non-repeat `Enter`/`Space` `keydown`, captured on the wrapper so it covers both the plain button and the CTAS dropdown button) and ignores the click if the button switched actions before release. A click with no preceding pointer or key press keeps using the current action. The same DOM element is kept, so focus and keyboard behaviour do not change. Paths checked: - Plain Run/Stop button and CTAS/CVAS `DropdownButton` main button: covered by the fix and tests. - Space (click on keyup) is covered; Enter clicks on keydown and is unaffected. - Run keyboard shortcuts (Ctrl+Enter / Ctrl+R) and the Stop shortcut (Ctrl+E / Ctrl+X) are separate keys in `SqlEditor`; the stop shortcut only calls `postStopQuery` when the latest query is running or pending, so it cannot execute SQL. - CTAS/CVAS menu items open a modal and start a new gesture; they do not reuse the button's click handler. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF Real Chrome (Playwright, headless) driving the actual component, with a query that runs for 1.5s. Each scenario starts one query (runs=1) before the gesture. | Gesture | Before | After | |---|---|---| | Pointer down on Stop, release after the query finishes | runs 1 → 2 | runs 1, stops 0 | | Space down on Stop, release after the query finishes | runs 1 → 2 | runs 1, stops 0 | | Same two gestures on the CTAS dropdown button | runs 1 → 2 | runs 1, stops 0 | | Plain click / Enter on Stop | stops 1 | stops 1 | | Abandoned press, then a fresh click on Run | runs 2 | runs 2 | ### TESTING INSTRUCTIONS - `npm run test -- src/SqlLab/components/RunQueryActionButton` — new tests cover a pointer gesture and a Space press that start on Stop and end after the query finishes, the CTAS dropdown variant, a Stop gesture that still stops, and a fresh gesture that still runs. The three Stop-to-Run tests and the fresh-gesture test fail on master. - Manual: in SQL Lab run a query that takes a few seconds, press and hold the mouse on **Stop**, wait for the query to finish, release. The query must not run again. ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] Required feature flags: - [x] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [ ] Introduces new feature or API - [ ] Removes existing feature or API -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
