Skip to content

Commit dad0eec

Browse files
Anders2303rubenthomslindjoha
authored
Replace Intersection and 3D viewer readout boxes with shared comp (#707)
Co-authored-by: Ruben Thoms <[email protected]> Co-authored-by: Øyvind Lind-Johansen <[email protected]> Co-authored-by: Ruben Thoms <[email protected]>
1 parent 335cf9e commit dad0eec

File tree

63 files changed

+468
-372
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+468
-372
lines changed

frontend/src/framework/WorkbenchServices.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import React from "react";
22

3-
import { Viewport } from "@framework/components/EsvIntersection/esvIntersection";
4-
53
import { isEqual } from "lodash";
64

75
import { EnsembleIdent } from "./EnsembleIdent";
86
import { Workbench } from "./Workbench";
97
import { InplaceVolumetricsFilter } from "./types/inplaceVolumetricsFilter";
108
import { Intersection } from "./types/intersection";
9+
import { Viewport } from "./types/viewport";
1110
import { Wellbore } from "./types/wellbore";
1211

1312
export type NavigatorTopicDefinitions = {

frontend/src/framework/components/EsvIntersection/utilityComponents/ReadoutBox.tsx

-173
This file was deleted.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type Viewport = [number, number, number];

frontend/src/lib/components/Select/select.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ export function Select<TValue = string>(props: SelectProps<TValue>) {
346346

347347
setCurrentFocusIndex(newCurrentKeyboardFocusIndex);
348348
setVirtualizationStartIndex(newVirtualizationStartIndex);
349+
setSelectionAnchor(newFilteredOptions.findIndex((option) => option.value === selectedOptionValues[0]));
349350
}
350351

351352
function handleFilterChange(event: React.ChangeEvent<HTMLInputElement>) {
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from "react";
2+
3+
import _ from "lodash";
4+
5+
/**
6+
* Deeply compares a variable with it's previous state, and returns a stable refference if the object is equivalent.
7+
* Useful for ensuring stable refferences when effects or memos depends on objects/arrays from props.
8+
* @param value Any variable, though this helper is only relevant for objects and arrays.
9+
* @returns A stable referrence to the object, and a boolean flag showing if the ref actually changed
10+
*/
11+
export function useStableProp<T>(value: T): [prop: T, propDidChange: boolean] {
12+
const [prevInternalValue, setPrevInternalValue] = React.useState<T>(value);
13+
14+
if (_.isEqual(value, prevInternalValue)) {
15+
return [prevInternalValue, false];
16+
}
17+
18+
setPrevInternalValue(value);
19+
return [value, true];
20+
}

frontend/src/modules/3DViewer/view/components/ReadoutBox.tsx

-155
This file was deleted.

0 commit comments

Comments
 (0)