Skip to content

workspace-search buttons need type=button #2510

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

Open
1 task done
admalledd opened this issue May 9, 2025 · 4 comments · May be fixed by #2551
Open
1 task done

workspace-search buttons need type=button #2510

admalledd opened this issue May 9, 2025 · 4 comments · May be fixed by #2551
Labels
category: plugin Anything in the plugins folder good first issue Good for newcomers help wanted Open for contributions size: small type: bug Something isn't working

Comments

@admalledd
Copy link

admalledd commented May 9, 2025

Check for duplicates

  • I have searched for similar issues before opening a new one.

Component

workspace-search's createBtn private helper method

Description

We are using Blockly inside a <form> element (for various reasons), and the existing createBtn function does not set the <button> to be <button type='button'> which means when users click them it erroneously causes a form-submit.

The fix should in theory works on my machine(tm), be as simple as changing the helper function to read something akin to:

  private createBtn(className: string, text: string): HTMLButtonElement {
    // Create the button
    const btn = document.createElement('button');
    Blockly.utils.dom.addClass(btn, className);
    btn.type = "button"; //++added++
    btn.setAttribute('aria-label', text);
    return btn;
  }

Reproduction steps

  1. Have a Blockly instance nested within a <form>
  2. Have the workspace-search plugin installed in the workspace
  3. ctrl-f for something, then hit any of the three buttons (next, prev, exit)
  4. Find that your HTML Form is now Submitted :(

Stack trace

Screenshots

No response

@admalledd admalledd added type: bug Something isn't working triage labels May 9, 2025
@maribethb maribethb added help wanted Open for contributions good first issue Good for newcomers category: plugin Anything in the plugins folder size: small and removed triage labels May 16, 2025
@maribethb
Copy link
Contributor

Hi @admalledd thanks for filing! We'd accept a PR for this if you'd like to submit your fix. Thanks!

@admalledd
Copy link
Author

@maribethb due to the language of my current work contract, that is difficult, hence provided the sample diff/line change in the issue above. I can open issues, discuss fixes, etc, but am not allowed to submit code under my own authorship if it relates to my work. :/

@viky-01
Copy link
Contributor

viky-01 commented May 25, 2025

@rachel-fenichel kindly review the fixes

@viky-01
Copy link
Contributor

viky-01 commented May 30, 2025

@BenHenning, apologies for the delay. Also, thanks for the support and patience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment