Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
Fix misspelled variable
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed Sep 18, 2021
1 parent 305bf53 commit 58286dc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/blocks/Table/TableBlockEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,9 @@ class Edit extends Component {
}

componentDidUpdate(prevProps) {
if (prevProps.select && !this.props.selected)
if (prevProps.selected && !this.props.selected) {
this.setState({ selected: null });
}
}

/**
Expand Down Expand Up @@ -648,6 +649,8 @@ class Edit extends Component {
key={cell.key}
as={cell.type === 'header' ? 'th' : 'td'}
className={
this.props.selected &&
this.state.selected &&
rowIndex === this.state.selected.row &&
cellIndex === this.state.selected.cell &&
this.props.selected
Expand All @@ -661,6 +664,8 @@ class Edit extends Component {
cell={cellIndex}
onSelectCell={this.onSelectCell}
selected={
this.props.selected &&
this.state.selected &&
rowIndex === this.state.selected.row &&
cellIndex === this.state.selected.cell
}
Expand All @@ -678,7 +683,7 @@ class Edit extends Component {
</Table.Body>
</Table>
)}
{this.props.selected && this.state.isClient && (
{this.props.selected && this.state.selected && this.state.isClient && (
<Portal node={document.getElementById('sidebar-properties')}>
<Form method="post" onSubmit={(event) => event.preventDefault()}>
<Segment secondary attached>
Expand Down
18 changes: 16 additions & 2 deletions src/editor/plugins/SimpleLink/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineMessages } from 'react-intl'; // , defineMessages
import { ReactEditor, useSlate } from 'slate-react';
import { useSelector, useDispatch } from 'react-redux';
import AddLinkForm from '@plone/volto/components/manage/AnchorPlugin/components/LinkButton/AddLinkForm';
import { isEqual } from 'lodash';
import {
_insertElement,
_unwrapElement,
Expand Down Expand Up @@ -56,6 +57,7 @@ const SimpleLinkEditor = (props) => {
getActiveElement,
unwrapElement,
insertElement,
isActiveElement,
} = props;
const showEditor = useSelector((state) => {
return state['slate_plugins']?.[pluginId]?.show_sidebar_editor;
Expand All @@ -65,7 +67,19 @@ const SimpleLinkEditor = (props) => {
const dispatch = useDispatch();

const active = getActiveElement(editor);
const [node] = active || [];
const isElement = isActiveElement(editor);

const [elementNode] = active || [];
const [savedActiveElement, setSavedActiveElement] = React.useState(null);

React.useEffect(() => {
if (isElement && !isEqual(elementNode, savedActiveElement)) {
setSavedActiveElement(elementNode);
// setFormData(elementNode.data || {});
} else if (!isElement) {
setSavedActiveElement(null);
}
}, [elementNode, isElement, savedActiveElement]);

if (showEditor && !savedPosition.current) {
savedPosition.current = getPositionStyle();
Expand All @@ -76,7 +90,7 @@ const SimpleLinkEditor = (props) => {
<AddLinkForm
block="draft-js"
placeholder={'Add link'}
data={{ url: node?.data?.url || '' }}
data={{ url: savedActiveElement?.data?.url || '' }}
theme={{}}
onChangeValue={(url) => {
if (!active) {
Expand Down

0 comments on commit 58286dc

Please sign in to comment.