Skip to content

Commit 1d3d927

Browse files
fix: ToggleWrapper button defaulting to submit type (#1823)
1 parent 554c6a3 commit 1d3d927

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

packages/core/src/blocks/ToggleWrapper/createToggleWrapper.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const createToggleWrapper = (
4141

4242
const toggleButton = document.createElement("button");
4343
toggleButton.className = "bn-toggle-button";
44+
toggleButton.type = "button";
4445
toggleButton.innerHTML =
4546
// 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
4647
'<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>';
@@ -75,6 +76,7 @@ export const createToggleWrapper = (
7576

7677
const toggleAddBlockButton = document.createElement("button");
7778
toggleAddBlockButton.className = "bn-toggle-add-block-button";
79+
toggleAddBlockButton.type = "button";
7880
toggleAddBlockButton.textContent = "Empty toggle. Click to add a block.";
7981
const toggleAddBlockButtonMouseDown = (event: MouseEvent) =>
8082
event.preventDefault();

packages/react/src/blocks/ToggleWrapper/ToggleWrapper.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export const ToggleWrapper = (
110110
<div className="bn-toggle-wrapper" data-show-children={showChildren}>
111111
<button
112112
className="bn-toggle-button"
113+
type="button"
113114
onMouseDown={(event) => event.preventDefault()}
114115
onClick={() => handleToggle(editor.getBlock(block)!)}
115116
>
@@ -129,6 +130,7 @@ export const ToggleWrapper = (
129130
{showChildren && childCount === 0 && (
130131
<button
131132
className="bn-toggle-add-block-button"
133+
type="button"
132134
onClick={() => {
133135
const updatedBlock = editor.updateBlock(block, {
134136
// Single empty block with default type.

0 commit comments

Comments
 (0)