Skip to content

Commit

Permalink
fix re-renders caused be reseting selected color ramp
Browse files Browse the repository at this point in the history
  • Loading branch information
lstillwe committed Sep 27, 2024
1 parent 97821ea commit 6a770f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@renci/apsviz-geostyler",
"version": "15.0.9",
"version": "15.0.10",
"description": "Framework for styling geodata",
"main": "dist/index.js",
"type": "module",
Expand Down
14 changes: 5 additions & 9 deletions src/Component/Symbolizer/ColorMapEditor/ColorMapEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,12 @@ export const ColorMapEditor: React.FC<ColorMapEditorProps> = (props) => {
return Object.keys(colorRamps).find(key => JSON.stringify(colorRamps[key]) === JSON.stringify(colorList));
};

// set the colorRamp to the one used in the current colormap
// TODO add colorRamp to CompositionContext
const [colorRamp, setColorRamp] = useState<string>(Object.keys(colorRamps)[0]);
let rampName = getColormapColorRampName();
const initalValue = rampName? rampName : Object.keys(colorRamps)[0]

const [colorRamp, setColorRamp] = useState<string>(initalValue);

const updateColorMap = (prop: string, value: any) => {
let newColorMap: ColorMap;
Expand Down Expand Up @@ -335,14 +339,6 @@ export const ColorMapEditor: React.FC<ColorMapEditorProps> = (props) => {
? FunctionUtil.evaluateFunction(colorMap?.type) as ColorMapType
: colorMap?.type;

// set the colorRamp to the one used in the current colormap
if (colorMap) {
const name = getColormapColorRampName();
if (name) {
setColorRamp(name);
}
}

const itemConfig = getFormItemConfig();

return (
Expand Down

0 comments on commit 6a770f9

Please sign in to comment.