File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed
packages/shared/widget-plugin-grid/src/selection Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -59,21 +59,21 @@ export function createSelectionHelper(
5959 add ( cleanup ) ;
6060 }
6161 if ( helper . type === "Single" && config . autoSelect ) {
62- const dispose = autorun ( ( ) => {
63- const { datasource, selection } = gate . props ;
64- const firstItem = datasource . items ?. [ 0 ] ;
62+ const dispose = autorun (
63+ ( ) => {
64+ const { datasource } = gate . props ;
65+ const firstItem = datasource . items ?. [ 0 ] ;
6566
66- if ( datasource . status === "available" ) {
67- if ( firstItem && ! selection ?. selection ) {
68- setTimeout ( ( ) => {
69- if ( ! gate . props . selection ?. selection ) {
70- ( gate . props . selection as SelectionSingleValue ) ?. setSelection ( firstItem ) ;
71- }
72- } , 0 ) ;
67+ if ( ! firstItem ) return ;
68+
69+ if ( helper . isSelected ( firstItem ) ) {
70+ dispose ( ) ;
71+ } else {
72+ helper . reduceTo ( firstItem ) ;
7373 }
74- dispose ( ) ;
75- }
76- } ) ;
74+ } ,
75+ { delay : 100 }
76+ ) ;
7777 add ( dispose ) ;
7878 }
7979 return disposeAll ;
You can’t perform that action at this time.
0 commit comments