Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React 18.2.0 in Volto core - and all that fun #3221

Merged
merged 43 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
191ae38
WIP
sneridagh Mar 31, 2022
1239b6d
Upgrade testing packages
sneridagh Apr 3, 2022
9c4edd5
Merge branch 'main' into react18
sneridagh Jan 17, 2024
dbdec2e
Update deps
sneridagh Jan 17, 2024
cd3ea48
Merge branch 'main' into react18
sneridagh Jan 17, 2024
414cd5e
Fix hydration errors
sneridagh Jan 19, 2024
316cadc
Fix listings and objectbrowser
sneridagh Jan 19, 2024
a67c68a
Fix some unit tests relative to snapshots
sneridagh Jan 22, 2024
9fe05d0
Merge branch 'main' into react18
sneridagh Jan 24, 2024
38af96e
Merge branch 'main' into react18
sneridagh Jan 24, 2024
3871c96
Fix unit tests :)
sneridagh Feb 1, 2024
0110e91
Merge branch 'main' into react18
sneridagh Feb 1, 2024
29f15dc
Fix linting
sneridagh Feb 1, 2024
7886ebd
Force acceptance videos on seamless
sneridagh Feb 1, 2024
83f7973
Changelog
sneridagh Feb 1, 2024
5883090
Changelog
sneridagh Feb 1, 2024
9b23a93
folder contents flaky test
sneridagh Feb 1, 2024
d1e385e
Upgrade Cypress
sneridagh Feb 1, 2024
f5e424d
Update actions
sneridagh Feb 1, 2024
7eed755
Problems with keys and the sidebar
sneridagh Feb 1, 2024
0827cc3
better tests
sneridagh Feb 1, 2024
9c5a4da
Revert "Upgrade Cypress"
sneridagh Feb 2, 2024
43efe5e
Add more guards
sneridagh Feb 2, 2024
50bd40e
Merge branch 'main' into react18
sneridagh Feb 2, 2024
3280026
Merge branch 'main' into react18
sneridagh Feb 2, 2024
33f71e4
Merge branch 'main' into react18
sneridagh Feb 5, 2024
e3688a2
Merge branch 'main' into react18
sneridagh Feb 7, 2024
cdedc2f
Merge branch 'main' into react18
sneridagh Feb 28, 2024
06563d2
Remove `react-portal` library
sneridagh Feb 28, 2024
9235ae2
Fix unit tests
sneridagh Feb 28, 2024
f86866c
Adjustments to the last commits
sneridagh Feb 29, 2024
acdc788
Fix slate insert break order T_T
sneridagh Feb 29, 2024
1a2918f
Add guard
sneridagh Feb 29, 2024
2af33b4
Fix unit
sneridagh Feb 29, 2024
c582221
Fix last slate Cypress fail
sneridagh Feb 29, 2024
6eb98f7
Add upgrade guide docs
sneridagh Feb 29, 2024
398a82c
Apply suggestions from code review
sneridagh Feb 29, 2024
bc190d7
Update packages/volto/src/components/manage/Form/Form.jsx
sneridagh Feb 29, 2024
857e990
Merge branch 'main' into react18
sneridagh Feb 29, 2024
4e85cca
Merge branch 'main' into react18
sneridagh Feb 29, 2024
51201ae
Fix tests
sneridagh Mar 1, 2024
8614e40
David's suggestions
sneridagh Mar 1, 2024
cfff829
Merge branch 'main' into react18
sneridagh Mar 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 55 additions & 55 deletions .github/workflows/acceptance.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
towncrier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# Fetch all history
fetch-depth: '0'
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
name: Prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# node setup
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}

Expand All @@ -29,7 +29,7 @@ jobs:
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v3
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
Expand All @@ -47,11 +47,11 @@ jobs:
name: ESlint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# node setup
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}

Expand All @@ -66,7 +66,7 @@ jobs:
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v3
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
Expand All @@ -87,11 +87,11 @@ jobs:
name: Stylelint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# node setup
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}

Expand All @@ -106,7 +106,7 @@ jobs:
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v3
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
Expand All @@ -127,11 +127,11 @@ jobs:
name: i18n
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# node setup
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}

Expand All @@ -146,7 +146,7 @@ jobs:
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v3
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
matrix:
python-version: ['3.10']
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
matrix:
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# node setup
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -33,7 +33,7 @@ jobs:
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v3
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
Expand Down Expand Up @@ -64,11 +64,11 @@ jobs:
matrix:
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# node setup
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -83,7 +83,7 @@ jobs:
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v3
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
Expand All @@ -105,11 +105,11 @@ jobs:
matrix:
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# node setup
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -124,7 +124,7 @@ jobs:
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v3
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
Expand All @@ -141,10 +141,10 @@ jobs:
name: '@plone/client'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}

Expand All @@ -159,7 +159,7 @@ jobs:
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v3
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
Expand Down
21 changes: 21 additions & 0 deletions docs/source/upgrade-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,27 @@ Thus it is safe to run it on top of your project and answer the prompts.

## Upgrading to Volto 18.x.x

### Volto runs now on React 18.2.0

We have updated Volto to use React 18.
This has been the latest published stable version since June 2022.
This aligns Volto with the latests developments in the React ecosystem and opens the door to up to date software and React features, like client side `Suspense` and others:

- Concurrent rendering in client (Suspense)
- Automatic batching updates
- Transitions
- New hooks `useId`, `useTransition`, `useDeferredValue`, `useSyncExternalStore`, and other hooks

### `react-portal` dependency removed

`react-portal` is deprecated and it was removed from Volto.
The Volto code that relied on it was mainly CMS UI components.
If your project relies on it, either in your code or the shadowed components you may have, you should update to use the standard React API, `createPortal`.
You can update your shadows taking the modified components as templates.
As a last resort, you can install `react-portal` as a dependency of your project.
However, this is discouraged, because the React 18 rendering could have unexpected side effects.
It is recommended that you use the React API instead.

### ESlint project configuration update

`@plone/registry` and [other packages on which Volto depends](https://github.com/plone/volto/tree/main/packages) are now stand-alone releases in the monorepo structure released in 18.0.0-alpha.4.
Expand Down
8 changes: 4 additions & 4 deletions packages/coresandbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
"react"
],
"peerDependencies": {
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-intl": "3.8.0",
"react-redux": "7.2.4",
"semantic-ui-react": "2.0.3"
},
"devDependencies": {
"@plone/types": "workspace:*",
"@types/react": "^18",
"@types/react-dom": "^18",
"@plone/registry": "workspace:*",
"@types/react": "^17.0.52",
"@types/react-dom": "^17",
"@types/react-redux": "^7.1.33"
}
}
1 change: 1 addition & 0 deletions packages/registry/news/3221.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade Volto core to use React 18.2.0 @sneridagh
6 changes: 4 additions & 2 deletions packages/registry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@
"@parcel/packager-ts": "2.10.2",
"@parcel/transformer-typescript-types": "2.10.2",
"@plone/types": "workspace:*",
"@types/react": "^17.0.52",
"@types/react-dom": "^17",
"@types/react": "^18",
"@types/react-dom": "^18",
"parcel": "2.10.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"release-it": "16.2.1",
"tsconfig": "workspace:*",
"typescript": "5.2.2",
Expand Down
1 change: 1 addition & 0 deletions packages/types/news/3221.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade Volto core to use React 18.2.0 @sneridagh
6 changes: 4 additions & 2 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@
"devDependencies": {
"@parcel/packager-ts": "2.10.2",
"@parcel/transformer-typescript-types": "2.10.2",
"@types/react": "^17.0.52",
"@types/react-dom": "^17",
"@types/react": "^18",
"@types/react-dom": "^18",
"history": "^5.3.0",
"parcel": "2.10.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-intl": "3.8.0",
"release-it": "16.2.1",
"tsconfig": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions packages/volto-slate/news/3221.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade Volto core to use React 18.2.0 @sneridagh
4 changes: 2 additions & 2 deletions packages/volto-slate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"image-extensions": "1.1.0",
"is-url": "1.2.4",
"jsdom": "^16.6.0",
"react": "17.0.2",
"react": "18.2.0",
"react-intersection-observer": "9.1.0",
"react-dom": "17.0.2",
"react-dom": "18.2.0",
"slate": "0.100.0",
"slate-history": "0.100.0",
"slate-hyperscript": "0.100.0",
Expand Down
15 changes: 7 additions & 8 deletions packages/volto-slate/src/blocks/Text/PluginSidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React from 'react';
import { Portal } from 'react-portal';
import { createPortal } from 'react-dom';

const PluginSidebar = ({ children, selected }) => {
return (
<>
{selected && (
<Portal
node={__CLIENT__ && document.getElementById('slate-plugin-sidebar')}
>
{children}
</Portal>
)}
{selected &&
__CLIENT__ &&
createPortal(
<>{children}</>,
document.getElementById('slate-plugin-sidebar'),
)}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export const breakList = (editor) => {
Editor.deleteBackward(editor, { unit: 'line' });
// also account for empty nodes [{text: ''}]
if (Editor.isEmpty(editor, parent)) {
Transforms.removeNodes(editor, { at: ref.current });
createAndSelectNewBlockAfter(editor, [createEmptyParagraph()]);
Transforms.removeNodes(editor, { at: ref.current });
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export const withSplitBlocksOnBreak = (editor) => {
// deconstructToVoltoBlocks
ReactDOM.unstable_batchedUpdates(() => {
const [top, bottom] = splitEditorInTwoFragments(editor);
setEditorContent(editor, top);
// ReactEditor.blur(editor);
createAndSelectNewBlockAfter(editor, bottom);
setEditorContent(editor, top);
});
}
return;
Expand Down
9 changes: 8 additions & 1 deletion packages/volto-slate/src/editor/SlateEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,14 @@ class SlateEditor extends Component {
ReactEditor.focus(editor);
Transforms.select(editor, selection);
} else {
Transforms.select(editor, Editor.end(editor, []));
try {
Transforms.select(editor, Editor.end(editor, []));
} catch (error) {
// Weird error only happening in Cypress
// Adding a try/catch
// eslint-disable-next-line no-console
console.log(error);
}
}

this.setState({
Expand Down
13 changes: 6 additions & 7 deletions packages/volto-slate/src/editor/ui/PositionedToolbar.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Portal } from 'react-portal';
import { createPortal } from 'react-dom';

import BasicToolbar from './BasicToolbar';

Expand All @@ -20,12 +20,11 @@ const PositionedToolbar = ({ toggleButton, className, children, position }) => {
el.style.left = left;
});

return (
<Portal>
<BasicToolbar className={`slate-inline-toolbar ${className}`} ref={ref}>
{children}
</BasicToolbar>
</Portal>
return createPortal(
<BasicToolbar className={`slate-inline-toolbar ${className}`} ref={ref}>
{children}
</BasicToolbar>,
document.body,
);
};

Expand Down
Loading
Loading