File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
superset-frontend/src/features/databases/DatabaseModal Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -191,4 +191,32 @@ describe('ExtraOptions Component', () => {
191
191
fireEvent . change ( input , { target : { value : '1000' } } ) ;
192
192
expect ( onExtraInputChange ) . toHaveBeenCalled ( ) ;
193
193
} ) ;
194
+
195
+ it ( 'renders the collaps tab correctly and resets to default tab after closing' , ( ) => {
196
+ const { rerender } = renderComponent ( ) ;
197
+ const sqlLabTab = screen . getByRole ( 'tab' , {
198
+ name : / S Q L L a b ./ i,
199
+ } ) ;
200
+
201
+ expect ( sqlLabTab ) . toHaveAttribute ( 'aria-expanded' , 'false' ) ;
202
+ fireEvent . click ( sqlLabTab ) ;
203
+ expect ( sqlLabTab ) . toHaveAttribute ( 'aria-expanded' , 'true' ) ;
204
+ const customDb = {
205
+ ...defaultDb ,
206
+ expose_in_sqllab : false ,
207
+ } ;
208
+
209
+ rerender (
210
+ < ExtraOptions
211
+ db = { customDb as unknown as DatabaseObject }
212
+ onInputChange = { onInputChange }
213
+ onTextChange = { onTextChange }
214
+ onEditorChange = { onEditorChange }
215
+ onExtraInputChange = { onExtraInputChange }
216
+ onExtraEditorChange = { onExtraEditorChange }
217
+ extraExtension = { undefined }
218
+ /> ,
219
+ ) ;
220
+ expect ( sqlLabTab ) . toHaveAttribute ( 'aria-expanded' , 'false' ) ;
221
+ } ) ;
194
222
} ) ;
Original file line number Diff line number Diff line change 16
16
* specific language governing permissions and limitations
17
17
* under the License.
18
18
*/
19
- import { ChangeEvent , EventHandler } from 'react' ;
19
+ import { ChangeEvent , EventHandler , useState , useEffect } from 'react' ;
20
20
import cx from 'classnames' ;
21
21
import {
22
22
t ,
@@ -88,12 +88,21 @@ const ExtraOptions = ({
88
88
const isAllowRunAsyncDisabled = isFeatureEnabled (
89
89
FeatureFlag . ForceSqlLabRunAsync ,
90
90
) ;
91
+ const [ activeKey , setActiveKey ] = useState < string [ ] | undefined > ( ) ;
92
+
93
+ useEffect ( ( ) => {
94
+ if ( ! expandableModalIsOpen && activeKey !== undefined ) {
95
+ setActiveKey ( undefined ) ;
96
+ }
97
+ } , [ expandableModalIsOpen , activeKey ] ) ;
91
98
92
99
return (
93
100
< Collapse
94
101
expandIconPosition = "end"
95
102
accordion
96
103
modalMode
104
+ activeKey = { activeKey }
105
+ onChange = { key => setActiveKey ( key ) }
97
106
items = { [
98
107
{
99
108
key : 'sql-lab' ,
You can’t perform that action at this time.
0 commit comments