     } 1|| ;
 
 M: table model-changed
-    nip dup update-selected-indices {
+    nip dup update-selected-indices [ V{ } clone ] unless* {
         [ >>selected-indices f >>mouse-index drop ]
-        [ peek show-row-summary ]
+        [ [ f ] [ peek ] if-empty show-row-summary ]
         [ drop update-selected-values ]
         [ drop relayout ]
     } 2cleave ;

: >>selected-index ( table n -- table ) over (>>selected-index) ;
: >>selected-value ( table val -- table ) over (>>selected-value) ;

M: table selected-value>> selected-values>> [ [ peek ] [ f ] if* ] <arrow> ;
M: table (>>selected-value) [ [ 1vector ] <arrow> ] dip (>>selected-values) ;
M: table selected-index>> selected-indices>> [ peek ] [ f ] if* ;
M: table (>>selected-index) [ 1vector ] dip (>>selected-indices) ;

IN: ui.gadgets.tables

: find-row-index ( value table -- n/f )
    [ model>> value>> ] [ renderer>> '[ _ row-value ] map index ] bi ;

: initial-selected-indices ( table -- {n}/f )
    {
        [ model>> value>> empty? not ]
        [ selection-required?>> ]
        [ drop V{ 0 } clone ]
    } 1&& ;

: (update-selected-indices) ( table -- {n}/f )
