@@ -743,6 +743,10 @@ function getHandleForPanelId(
743743) {
744744 const panelIndex = context . items . findIndex ( ( item ) => item . id === panelId ) ;
745745
746+ // When in controlled collapse mode we defer to the controlled state to know if we need to update.
747+ // The confirmation comes along as an expand/collapse event.
748+ // The default behavior is to find the closes handle and use that to collapse, if we're dragging some other
749+ // handle though we want to use that instead. This will results in a smoother visual experience.
746750 if ( context . activeDragHandleId ) {
747751 const handleIndex = getPanelHandleIndex (
748752 context ,
@@ -853,14 +857,10 @@ function panelHasSpace(
853857 `panelHasSpace only works with number values: ${ item . id } ${ item . currentValue } `
854858 ) ;
855859
856- if ( adjustment === "subtract" && item . collapsible ) {
860+ if ( item . collapsible ) {
857861 return ! item . collapsed ;
858862 }
859863
860- if ( adjustment === "add" && item . collapsible ) {
861- return item . collapsed ? false : true ;
862- }
863-
864864 if ( adjustment === "add" ) {
865865 return (
866866 item . currentValue . value . gte ( getUnitPixelValue ( context , item . min ) ) &&
@@ -2260,11 +2260,11 @@ export function groupMachine(
22602260 ( output ) => {
22612261 actions . onAnimationEnd ( output ) ;
22622262 transition ( "idle" ) ;
2263+ panel . collapsed = true ;
2264+ panel . onCollapseChange ?. current ?.( true ) ;
22632265 if ( event . resolve ) {
22642266 requestAnimationFrame ( event . resolve ) ;
22652267 }
2266- panel . collapsed = true ;
2267- panel . onCollapseChange ?. current ?.( true ) ;
22682268 }
22692269 ) ;
22702270 }
0 commit comments