@@ -1262,21 +1262,20 @@ export class Datetime implements ComponentInterface {
12621262 }
12631263
12641264 /**
1265- * If there are multiple values, pick an arbitrary one to clamp to. This way,
1266- * if the values are across months, we always show at least one of them. Note
1267- * that the values don't necessarily have to be in order .
1265+ * If there are multiple values, clamp to the last one.
1266+ * This is because the last value is the one that the user
1267+ * has most recently interacted with .
12681268 */
1269- const singleValue = Array . isArray ( valueToProcess ) ? valueToProcess [ 0 ] : valueToProcess ;
1269+ const singleValue = Array . isArray ( valueToProcess ) ? valueToProcess [ valueToProcess . length - 1 ] : valueToProcess ;
12701270 const targetValue = clampDate ( singleValue , minParts , maxParts ) ;
12711271
12721272 const { month, day, year, hour, minute } = targetValue ;
12731273 const ampm = parseAmPm ( hour ! ) ;
12741274
12751275 /**
1276- * Since `activeParts` indicates a value that
1277- * been explicitly selected either by the
1278- * user or the app, only update `activeParts`
1279- * if the `value` property is set.
1276+ * Since `activeParts` indicates a value that been explicitly selected
1277+ * either by the user or the app, only update `activeParts` if the
1278+ * `value` property is set.
12801279 */
12811280 if ( hasValue ) {
12821281 if ( Array . isArray ( valueToProcess ) ) {
@@ -1300,28 +1299,21 @@ export class Datetime implements ComponentInterface {
13001299 this . activeParts = [ ] ;
13011300 }
13021301
1303- /**
1304- * Only animate if:
1305- * 1. We're using grid style (wheel style pickers should just jump to new value)
1306- * 2. The month and/or year actually changed, and both are defined (otherwise there's nothing to animate to)
1307- * 3. The calendar body is visible (prevents animation when in collapsed datetime-button, for example)
1308- * 4. The month/year picker is not open (since you wouldn't see the animation anyway)
1309- */
13101302 const didChangeMonth =
13111303 ( month !== undefined && month !== workingParts . month ) || ( year !== undefined && year !== workingParts . year ) ;
13121304 const bodyIsVisible = el . classList . contains ( 'datetime-ready' ) ;
13131305 const { isGridStyle, showMonthAndYear } = this ;
13141306
13151307 if ( isGridStyle && didChangeMonth && bodyIsVisible && ! showMonthAndYear ) {
13161308 /**
1317- * Animate to the target date, either the first value in the array or the single value.
1309+ * Only animate if:
1310+ * 1. We're using grid style (wheel style pickers should just jump to new value)
1311+ * 2. The month and/or year actually changed, and both are defined (otherwise there's nothing to animate to)
1312+ * 3. The calendar body is visible (prevents animation when in collapsed datetime-button, for example)
1313+ * 4. The month/year picker is not open (since you wouldn't see the animation anyway)
13181314 */
13191315 this . animateToDate ( targetValue ) ;
13201316 } else {
1321- /**
1322- * We only need to do this if we didn't just animate to a new month,
1323- * since that calls prevMonth/nextMonth which calls setWorkingParts for us.
1324- */
13251317 this . setWorkingParts ( {
13261318 month,
13271319 day,
0 commit comments