File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed
Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ export const GraphSidebar = () => {
1818
1919 const [ graphCellId , setGraphCellId ] = useState < CellId > ( graph . cells [ 0 ] ?. id ) ;
2020
21+ useEffect ( ( ) => {
22+ setGraphCellId ( graph . cells [ 0 ] ?. id ) ;
23+ } , [ graph . cells ] ) ;
24+
2125 useEffect ( ( ) => {
2226 document . getElementById ( GRAPH_RENDERER_ID ) . innerHTML = "" ;
2327
Original file line number Diff line number Diff line change @@ -179,11 +179,23 @@ export namespace SpreadsheetUtils {
179179 } ;
180180
181181 export const tryGetFormulaFromCellValue = ( input : string ) => {
182- if ( ! isNaN ( Number ( input ) ) && input . trim ( ) !== "" ) {
182+ if ( input . trim ( ) === "" ) {
183+ return "" ;
184+ }
185+
186+ if ( input . trim ( ) . startsWith ( "=" ) ) {
187+ return input . trim ( ) ;
188+ }
189+
190+ if ( ! isNaN ( Number ( input ) ) ) {
183191 return `= ${ input . trim ( ) } ` ;
184192 }
185193
186- return input . trim ( ) ;
194+ if ( [ "TRUE" , "FALSE" ] . includes ( input . trim ( ) . toUpperCase ( ) ) ) {
195+ return `= ${ input . trim ( ) . toUpperCase ( ) } ` ;
196+ }
197+
198+ return `= "${ input . trim ( ) } "` ;
187199 } ;
188200
189201 export const getValueText = ( value : Value ) => {
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ export const GraphProvider = ({ children }: { children: ReactNode }) => {
3535 for ( const cellId of spreadsheet . cells . usedCells ) {
3636 const value =
3737 spreadsheet . history . history . get ( cellId ) ?. [ stepper . step ] ;
38+
3839 if ( ! value || value . type !== ValueType . Graph ) continue ;
3940 graphCells . push ( {
4041 id : cellId ,
@@ -43,7 +44,11 @@ export const GraphProvider = ({ children }: { children: ReactNode }) => {
4344 }
4445
4546 setCells ( graphCells ) ;
46- } , [ spreadsheet . cells . usedCells ] ) ;
47+ } , [
48+ spreadsheet . cells . usedCells ,
49+ spreadsheet . history . history ,
50+ stepper . step ,
51+ ] ) ;
4752
4853 const values = {
4954 cells,
You can’t perform that action at this time.
0 commit comments