Skip to content

Commit

Permalink
Fix click event in edit mode
Browse files Browse the repository at this point in the history
- clicking on toggle does the toggle but also bubbles to select the block
- clicking on title does not toggle but also bubbles to select the block
  • Loading branch information
reebalazs committed Oct 3, 2024
1 parent 62a9db5 commit dea6336
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/volto-accordion-block/src/components/AccordionEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ const AccordionEdit = (props) => {
const isActive = activeIndex.includes(index);

const handleClick = (e, itemProps) => {
e.stopPropagation();
// If the title was clicked, bail out, let the event bubble.
if (e.preventToggle) {
return;
}
// Do not stop propagation, bubbling is needed for the editor to select the block.
const { index } = itemProps;
if (data.non_exclusive) {
const newIndex =
Expand Down Expand Up @@ -47,6 +51,7 @@ const AccordionEdit = (props) => {
<div
className={cx('accordion-title')}
onClick={(e) => handleClick(e, { index })}
onKeyDown={(e) => null}
role="button"
tabIndex={0}
aria-expanded={isActive}
Expand All @@ -56,7 +61,9 @@ const AccordionEdit = (props) => {
value={panel?.title}
onClick={(e) => {
handleTitleClick();
e.stopPropagation();
// Do not stop propagation, bubbling is needed for the editor to select the block.
// However mark the event so we ignore the open/close.
e.preventToggle = true;
}}
onChange={(e) => handleTitleChange(e, [uid, panel])}
/>
Expand Down

0 comments on commit dea6336

Please sign in to comment.