Skip to content

Commit

Permalink
fix: 🐛 Details: add clickListener to Summary field (#17)
Browse files Browse the repository at this point in the history
fix: 🐛 Details: add clickListener to Summary field  Fixes #9
  • Loading branch information
Herm71 authored Aug 4, 2023
1 parent 8bfe9eb commit e466a30
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions blocks/src/details/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import { useSelect } from '@wordpress/data';
import { PanelBody, ToggleControl } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { SPACE } from '@wordpress/keycodes';
import './editor.scss';

export default function Edit( { attributes, setAttributes, clientId } ) {
Expand All @@ -21,10 +20,9 @@ export default function Edit( { attributes, setAttributes, clientId } ) {
const onChangeSummary = ( newSummary ) => {
setAttributes( { summary: newSummary } );
};
const keyUpListener = ( e ) => {
if ( e.keyCode === SPACE ) {
e.preventDefault();
}

const clickListener = (e) => {
e.preventDefault();
};
// Check if either the block or the inner blocks are selected.
const hasSelection = useSelect(
Expand Down Expand Up @@ -60,7 +58,7 @@ export default function Edit( { attributes, setAttributes, clientId } ) {
{ ...innerBlocksProps }
open={ hasSelection || showContent }
>
<summary className="dashicons-before" onKeyUp={ keyUpListener }>
<summary className="dashicons-before" onClick={ clickListener }>
<RichText
value={ summary }
onChange={ onChangeSummary }
Expand Down

0 comments on commit e466a30

Please sign in to comment.