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

STCOM-1235 validate refs before dereferencing them #2257

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 12.2.0 IN PROGRESS

* Exclude invalid additional currencies. Refs STCOM-1274.
* Validate ref in `Paneset` before dereferencing it. Refs STCOM-1235.

## [12.1.0](https://github.com/folio-org/stripes-components/tree/v12.1.0) (2024-03-12)
[Full Changelog](https://github.com/folio-org/stripes-components/compare/v12.0.0...v12.1.0)
Expand Down
12 changes: 8 additions & 4 deletions lib/Paneset/insertByClientRect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
import cloneDeep from 'lodash/cloneDeep';

export default (prevArray, newItem) => {
const newClientRect = newItem.getRef().current.getBoundingClientRect();
const nextIndex = prevArray.findIndex((p) => {
return (p.getRef().current.getBoundingClientRect().left > newClientRect.left);
});
let nextIndex = -1;
if (newItem.getRef().current) {
const newClientRect = newItem.getRef().current.getBoundingClientRect();
nextIndex = prevArray.findIndex((p) => {
return (p.getRef().current.getBoundingClientRect().left > newClientRect.left);
});
}

let newArray;
if (nextIndex === -1) {
newArray = [...prevArray, newItem];
Expand Down
Loading