1- import { Box , Button , FormControl , FormHelperText , InputLabel , MenuItem , Select } from "@mui/material" ;
1+ import { Box , Button , FormControl , FormHelperText , InputLabel , MenuItem , Select , CircularProgress } from "@mui/material" ;
22import React from "react" ;
33
44import "./visualization-tool-box.css" ;
@@ -16,14 +16,15 @@ export class VisualizationToolBox extends React.Component<{
1616 polymerColor : PolymerColorType ,
1717 onPolymerViewChange : ( polymerView : PolymerViewType ) => void ,
1818 onPocketsViewChange : ( pocketsView : PocketsViewType ) => void ,
19- onPolymerColorChange : ( polymerColor : PolymerColorType ) => void ,
19+ onPolymerColorChange : ( polymerColor : PolymerColorType ) => Promise < void > ,
2020 onShowConfidentChange : ( ) => void ,
2121} , {
2222 polymerView : PolymerViewType ,
2323 pocketsView : PocketsViewType ,
2424 polymerColor : PolymerColorType ,
2525 is1DViewerVisible : boolean ,
26- isShowOnlyPredicted : boolean ;
26+ isShowOnlyPredicted : boolean ,
27+ isColoringPolymer : boolean ;
2728} > {
2829
2930 constructor ( props : any ) {
@@ -42,7 +43,8 @@ export class VisualizationToolBox extends React.Component<{
4243 pocketsView : this . props . pocketsView ,
4344 polymerColor : this . props . polymerColor ,
4445 is1DViewerVisible : true ,
45- isShowOnlyPredicted : false
46+ isShowOnlyPredicted : false ,
47+ isColoringPolymer : false
4648 } ;
4749 }
4850
@@ -81,9 +83,18 @@ export class VisualizationToolBox extends React.Component<{
8183 this . props . onPocketsViewChange ( pocketsView ) ;
8284 }
8385
84- changePolymerColor ( polymerColor : PolymerColorType ) {
85- this . setState ( { polymerColor : polymerColor } ) ;
86- this . props . onPolymerColorChange ( polymerColor ) ;
86+ async changePolymerColor ( polymerColor : PolymerColorType ) {
87+ this . setState ( { polymerColor : polymerColor , isColoringPolymer : true } , async ( ) => {
88+ try {
89+ // Wait for next frame to ensure UI updates
90+ await new Promise ( resolve => setTimeout ( resolve , 0 ) ) ;
91+ await this . props . onPolymerColorChange ( polymerColor ) ;
92+ } catch ( error ) {
93+ console . error ( "Error changing polymer color:" , error ) ;
94+ } finally {
95+ this . setState ( { isColoringPolymer : false } ) ;
96+ }
97+ } ) ;
8798 }
8899
89100 changeShowConfident ( ) {
@@ -138,7 +149,7 @@ export class VisualizationToolBox extends React.Component<{
138149 </ div >
139150 </ div >
140151
141- < div className = "visualization-toolbox-option" >
152+ < div className = "visualization-toolbox-option visualization-toolbox-option-relative " >
142153 < div className = "visualization-toolbox-option-description" >
143154 < FormControl size = "small" className = "visualization-toolbox-formcontrol" >
144155 < Select
@@ -147,6 +158,7 @@ export class VisualizationToolBox extends React.Component<{
147158 value = { this . state . polymerColor }
148159 onChange = { ( event ) => this . changePolymerColor ( event . target . value as PolymerColorType ) }
149160 className = "visualization-toolbox-select"
161+ disabled = { this . state . isColoringPolymer }
150162 >
151163 < MenuItem value = { PolymerColorType . White } > White</ MenuItem >
152164 { this . scoresDataAvailable ( this . props . predictionData . structure . scores . conservation ) &&
@@ -156,6 +168,11 @@ export class VisualizationToolBox extends React.Component<{
156168 </ Select >
157169 < FormHelperText sx = { { textAlign : "center" } } > Polymer coloring</ FormHelperText >
158170 </ FormControl >
171+ { this . state . isColoringPolymer && (
172+ < div className = "visualization-toolbox-loading-overlay" >
173+ < CircularProgress size = { 24 } />
174+ </ div >
175+ ) }
159176 </ div >
160177 </ div >
161178 </ div >
0 commit comments