File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,15 @@ export default class extends React.Component {
7878 }
7979 }
8080
81+ componentDidUpdate ( ) {
82+ ObjectAttributes . set (
83+ this . rjvId ,
84+ 'global' ,
85+ 'src' ,
86+ this . props . src
87+ ) ;
88+ }
89+
8190 init = ( props ) => {
8291 for ( let i in this . defaults ) {
8392 if ( props [ i ] !== undefined ) {
Original file line number Diff line number Diff line change @@ -121,6 +121,36 @@ describe('<VariableEditor />', function () {
121121 ) . to . equal ( 0 ) ;
122122 } ) ;
123123
124+ it ( 'VariableEditor edit after src change should respect current src' , function ( ) {
125+ const oldSrc = { edited : true , other : 'old' } ;
126+ const currentSrc = { edited : true , other : 'current' } ;
127+
128+ const wrapper = mount (
129+ < Index
130+ src = { oldSrc }
131+ theme = 'rjv-default'
132+ onEdit = { ( edit ) => {
133+ expect ( edit . updated_src . other ) . to . equal ( currentSrc . other ) ;
134+ return true ;
135+ } }
136+ rjvId = { rjvId }
137+ />
138+ ) ;
139+ wrapper . setProps ( { src : currentSrc } ) ;
140+
141+ wrapper . find ( '.click-to-edit-icon' ) . first ( ) . simulate ( 'click' ) ;
142+ expect (
143+ wrapper . state ( 'onEdit' )
144+ ) . to . not . equal ( false ) ;
145+ expect (
146+ wrapper . find ( '.variable-editor' ) . length
147+ ) . to . equal ( 1 ) ;
148+ wrapper . find ( '.edit-check.string-value' ) . simulate ( 'click' ) ;
149+ expect (
150+ wrapper . find ( '.variable-editor' ) . length
151+ ) . to . equal ( 0 ) ;
152+ } ) ;
153+
124154 it ( 'VariableEditor detected null' , function ( ) {
125155 const wrapper = shallow (
126156 < VariableEditor
You can’t perform that action at this time.
0 commit comments