plotly / react-chart-editor

Customizable React-based editor panel for Plotly charts
https://plotly.github.io/react-chart-editor/
MIT License
499 stars 101 forks source link

Incorrect styling for foldable section #1122

Closed johanbook closed 3 years ago

johanbook commented 3 years ago

I tried following the simple example and spinning up react-chart-editor, but it seems some styling is incorrect as seen in attached image.

2021-02-15-103947_1920x1080_scrot

I run the editor as

import "react-chart-editor/lib/react-chart-editor.min.css";

import * as React from "react";
// @ts-ignore // exists no types for `react-chart-editor`
import PlotlyEditor from "react-chart-editor";

// @ts-ignore // types not available for `plotly.js/dist`
import plotly from "plotly.js/dist/plotly";

const EDITOR_CONFIG = { editable: true };

...

export function DataExplorer({
  data,
  dataSourceOptions,
}: SomeProps): React.ReactElement {
  const [state, setState] = React.useState({
    data: [],
    layout: {},
    frames: [],
  });

  return (
    <PlotlyEditor
      advancedTraceTypeSelector
      config={EDITOR_CONFIG}
      data={state.data}
      frames={state.frames}
      layout={state.layout}
      dataSources={data}
      dataSourceOptions={dataSourceOptions}
      plotly={plotly}
      onUpdate={(data: any, layout: any, frames: any) =>
        setState({ data, layout, frames })
      }
      useResizeHandler
    />
  );
}

With versions

"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "^4.0.1",

Have I missed something?

dmt0 commented 3 years ago

@johanbook Could you try running it with React 16?

johanbook commented 3 years ago

I created a basic template with Create-React-App with React 17 and then managed to run this code without the issue so it's likely some issue in some other part of my code base

johanbook commented 3 years ago

It seems is the same as https://github.com/plotly/react-chart-editor/issues/745 and the problem is to the css property box-sizing being set by a style library (Material UI). I fixed it by adding the equivalent of

.folder {
  box-sizing: "content-box"
}

to the global css. Works but not the prettiest