Skip to content

Commit

Permalink
fix: selection in TextEditorWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliaghisini committed Oct 6, 2023
1 parent a71b16b commit 3cf2838
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/components/ItaliaTheme/manage/Widgets/TextEditorWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,20 @@ const TextEditorWidget = (props) => {
});

const _value = value ?? data[fieldName];

const selectThis = () => {
if (onSelectBlock) {
onSelectBlock(block);
} else {
setSelected();
}
};
return (
<div
className={wrapClass}
onClick={() => setSelected()}
onFocus={() => setSelected()}
onKeyDown={() => setSelected()}
onClick={() => selectThis()}
onFocus={() => selectThis()}
onKeyDown={() => selectThis()}
role={'textbox'}
tabIndex="-1"
>
Expand All @@ -88,11 +96,7 @@ const TextEditorWidget = (props) => {
slateSettings={otherProps.slateSettings}
onFocus={() => {
if (!selected) {
if (onSelectBlock) {
onSelectBlock(block);
} else {
setSelected();
}
selectThis();
}
}}
onChange={(value, selection, editor) => {
Expand Down

0 comments on commit 3cf2838

Please sign in to comment.