Skip to content

Commit

Permalink
Remove react-portal library
Browse files Browse the repository at this point in the history
  • Loading branch information
sneridagh committed Feb 28, 2024
1 parent cdedc2f commit 06563d2
Show file tree
Hide file tree
Showing 46 changed files with 405 additions and 400 deletions.
1 change: 0 additions & 1 deletion packages/volto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@
"react-intl-redux": "2.3.0",
"react-medium-image-zoom": "3.0.15",
"react-popper": "^2.3.0",
"react-portal": "4.2.1",
"react-redux": "8.1.2",
"react-router": "5.2.0",
"react-router-config": "5.1.1",
Expand Down
20 changes: 9 additions & 11 deletions packages/volto/src/components/manage/Add/Add.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { compose } from 'redux';
import { keys, isEmpty } from 'lodash';
import { defineMessages, injectIntl } from 'react-intl';
import { Button, Grid, Menu } from 'semantic-ui-react';
import { Portal } from 'react-portal';
import { createPortal } from 'react-dom';
import { v4 as uuid } from 'uuid';
import qs from 'query-string';
import { toast } from 'react-toastify';
Expand Down Expand Up @@ -366,8 +366,8 @@ class Add extends Component {
}}
global
/>
{this.state.isClient && (
<Portal node={document.getElementById('toolbar')}>
{this.state.isClient &&
createPortal(
<Toolbar
pathname={this.props.pathname}
hideDefaultViewButtons
Expand Down Expand Up @@ -400,14 +400,12 @@ class Add extends Component {
</Button>
</>
}
/>
</Portal>
)}
{visual && this.state.isClient && (
<Portal node={document.getElementById('sidebar')}>
<Sidebar />
</Portal>
)}
/>,
document.getElementById('toolbar'),
)}
{visual &&
this.state.isClient &&
createPortal(<Sidebar />, document.getElementById('sidebar'))}
</div>
);

Expand Down
12 changes: 6 additions & 6 deletions packages/volto/src/components/manage/Aliases/Aliases.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Helmet } from '@plone/volto/helpers';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { Link } from 'react-router-dom';
import { Portal } from 'react-portal';
import { createPortal } from 'react-dom';
import {
Button,
Checkbox,
Expand Down Expand Up @@ -317,8 +317,8 @@ class Aliases extends Component {
</Segment>
</Form>
</Segment.Group>
{this.state.isClient && (
<Portal node={document.getElementById('toolbar')}>
{this.state.isClient &&
createPortal(
<Toolbar
pathname={this.props.pathname}
hideDefaultViewButtons
Expand All @@ -335,9 +335,9 @@ class Aliases extends Component {
/>
</Link>
}
/>
</Portal>
)}
/>,
document.getElementById('toolbar'),
)}
</Container>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import config from '@plone/volto/registry';
import { Button, Ref } from 'semantic-ui-react';
import { defineMessages, useIntl } from 'react-intl';
import { usePopper } from 'react-popper';
import { Portal } from 'react-portal';
import { createPortal } from 'react-dom';

const messages = defineMessages({
addBlock: {
Expand Down Expand Up @@ -115,8 +115,8 @@ const BlockChooserButton = (props) => {
/>
</Ref>
)}
{addNewBlockOpened && (
<Portal node={document.getElementById('body')}>
{addNewBlockOpened &&
createPortal(
<div
ref={setPopperElement}
style={styles.popper}
Expand Down Expand Up @@ -148,9 +148,9 @@ const BlockChooserButton = (props) => {
navRoot={navRoot}
contentType={contentType}
/>
</div>
</Portal>
)}
</div>,
document.getElementById('body'),
)}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const BlocksForm = (props) => {
};

const onInsertBlock = (id, value, current) => {
// debugger;
const [newId, newFormData] = insertBlock(
properties,
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BlockChooser, Icon } from '@plone/volto/components';
import { useDetectClickOutside } from '@plone/volto/helpers';
import addSVG from '@plone/volto/icons/add.svg';
import { usePopper } from 'react-popper';
import { Portal } from 'react-portal';
import { createPortal } from 'react-dom';

const messages = defineMessages({
addBlock: {
Expand Down Expand Up @@ -59,24 +59,25 @@ const NewBlockAddButton = (props) => {
<Icon name={addSVG} className="circled" size="24px" />
</Button>
</Ref>
{isOpenMenu ? (
<Portal node={document.getElementById('body')}>
<div
ref={setPopperElement}
style={styles.popper}
{...attributes.popper}
className="container-chooser-wrapper"
>
<BlockChooser
onMutateBlock={onMutateBlock}
currentBlock={block}
showRestricted
blocksConfig={blocksConfig}
ref={blockChooserRef}
/>
</div>
</Portal>
) : null}
{isOpenMenu
? createPortal(
<div
ref={setPopperElement}
style={styles.popper}
{...attributes.popper}
className="container-chooser-wrapper"
>
<BlockChooser
onMutateBlock={onMutateBlock}
currentBlock={block}
showRestricted
blocksConfig={blocksConfig}
ref={blockChooserRef}
/>
</div>,
document.getElementById('body'),
)
: null}
</>
);
};
Expand Down
13 changes: 7 additions & 6 deletions packages/volto/src/components/manage/Blocks/Table/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
import { compose } from 'redux';
import { map, remove } from 'lodash';
import { Button, Segment, Table, Form } from 'semantic-ui-react';
import { Portal } from 'react-portal';
import { createPortal } from 'react-dom';
import cx from 'classnames';
import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';

Expand Down Expand Up @@ -670,8 +670,9 @@ class Edit extends Component {
</Table.Body>
</Table>
)}
{this.props.selected && this.state.isClient && (
<Portal node={document.getElementById('sidebar-properties')}>
{this.props.selected &&
this.state.isClient &&
createPortal(
<Form
method="post"
onSubmit={(event) => {
Expand Down Expand Up @@ -736,9 +737,9 @@ class Edit extends Component {
onChange={this.toggleCellType}
/>
</Segment>
</Form>
</Portal>
)}
</Form>,
document.getElementById('sidebar-properties'),
)}
</div>
);
}
Expand Down
12 changes: 6 additions & 6 deletions packages/volto/src/components/manage/Contents/Contents.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { Portal } from 'react-portal';
import { createPortal } from 'react-dom';
import { Link } from 'react-router-dom';
import {
Button,
Expand Down Expand Up @@ -2159,8 +2159,8 @@ class Contents extends Component {
</section>
</article>
</div>
{this.state.isClient && (
<Portal node={document.getElementById('toolbar')}>
{this.state.isClient &&
createPortal(
<Toolbar
pathname={this.props.pathname}
inner={
Expand All @@ -2178,9 +2178,9 @@ class Contents extends Component {
/>
</Link>
}
/>
</Portal>
)}
/>,
document.getElementById('toolbar'),
)}
</Dimmer.Dimmable>
</Container>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { Link } from 'react-router-dom';
import { Portal } from 'react-portal';
import { createPortal } from 'react-dom';
import {
Accordion,
Button,
Expand Down Expand Up @@ -550,8 +550,8 @@ class AddonsControlpanel extends Component {
)}
</Segment.Group>

{this.state.isClient && (
<Portal node={document.getElementById('toolbar')}>
{this.state.isClient &&
createPortal(
<Toolbar
pathname={this.props.pathname}
hideDefaultViewButtons
Expand All @@ -568,9 +568,9 @@ class AddonsControlpanel extends Component {
</Link>
</>
}
/>
</Portal>
)}
/>,
document.getElementById('toolbar'),
)}
</Container>
);
}
Expand Down
12 changes: 6 additions & 6 deletions packages/volto/src/components/manage/Controlpanels/Aliases.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { compose } from 'redux';
import { Link } from 'react-router-dom';
import { getBaseUrl, getParentUrl, Helmet } from '@plone/volto/helpers';
import { removeAliases, addAliases, getAliases } from '@plone/volto/actions';
import { Portal } from 'react-portal';
import { createPortal } from 'react-dom';
import {
Container,
Button,
Expand Down Expand Up @@ -652,8 +652,8 @@ class Aliases extends Component {
</Segment.Group>
</article>
</Container>
{this.state.isClient && (
<Portal node={document.getElementById('toolbar')}>
{this.state.isClient &&
createPortal(
<Toolbar
pathname={this.props.pathname}
hideDefaultViewButtons
Expand All @@ -667,9 +667,9 @@ class Aliases extends Component {
/>
</Link>
}
/>
</Portal>
)}
/>,
document.getElementById('toolbar'),
)}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { getParentUrl } from '@plone/volto/helpers';
import { Portal } from 'react-portal';
import { createPortal } from 'react-dom';
import { Button, Header } from 'semantic-ui-react';
import { defineMessages, injectIntl } from 'react-intl';
import { toast } from 'react-toastify';
Expand Down Expand Up @@ -210,8 +210,8 @@ class ContentType extends Component {
hideActions
loading={this.props.cpanelRequest.update.loading}
/>
{this.state.isClient && (
<Portal node={document.getElementById('toolbar')}>
{this.state.isClient &&
createPortal(
<Toolbar
pathname={this.props.pathname}
hideDefaultViewButtons
Expand Down Expand Up @@ -248,9 +248,9 @@ class ContentType extends Component {
</Button>
</>
}
/>
</Portal>
)}
/>,
document.getElementById('toolbar'),
)}
</div>
);
}
Expand Down
Loading

0 comments on commit 06563d2

Please sign in to comment.