Skip to content

fix: ToggleWrapper button defaulting to submit type #1823

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

Merged
merged 2 commits into from
Jul 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/core/src/blocks/ToggleWrapper/createToggleWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const createToggleWrapper = (

const toggleButton = document.createElement("button");
toggleButton.className = "bn-toggle-button";
toggleButton.type = "button";
toggleButton.innerHTML =
// https://fonts.google.com/icons?selected=Material+Symbols+Rounded:chevron_right:FILL@0;wght@700;GRAD@0;opsz@24&icon.query=chevron&icon.style=Rounded&icon.size=24&icon.color=%23e8eaed
'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="CURRENTCOLOR"><path d="M320-200v-560l440 280-440 280Z"/></svg>';
Expand Down Expand Up @@ -75,6 +76,7 @@ export const createToggleWrapper = (

const toggleAddBlockButton = document.createElement("button");
toggleAddBlockButton.className = "bn-toggle-add-block-button";
toggleAddBlockButton.type = "button";
toggleAddBlockButton.textContent = "Empty toggle. Click to add a block.";
const toggleAddBlockButtonMouseDown = (event: MouseEvent) =>
event.preventDefault();
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/blocks/ToggleWrapper/ToggleWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const ToggleWrapper = (
<div className="bn-toggle-wrapper" data-show-children={showChildren}>
<button
className="bn-toggle-button"
type="button"
onMouseDown={(event) => event.preventDefault()}
onClick={() => handleToggle(editor.getBlock(block)!)}
>
Expand All @@ -129,6 +130,7 @@ export const ToggleWrapper = (
{showChildren && childCount === 0 && (
<button
className="bn-toggle-add-block-button"
type="button"
onClick={() => {
const updatedBlock = editor.updateBlock(block, {
// Single empty block with default type.
Expand Down
Loading