@@ -821,6 +821,21 @@ export class DirListing extends Widget {
821821 : 'short' ;
822822 }
823823
824+ // Update only the modified dates.
825+ protected updateModified ( items : Contents . IModel [ ] , nodes : HTMLElement [ ] ) {
826+ items . forEach ( ( item , i ) => {
827+ const node = nodes [ i ] ;
828+ if ( item . last_modified ) {
829+ const modified = DOMUtils . findElement ( node , ITEM_MODIFIED_CLASS ) ;
830+ this . renderer . updateItemModified (
831+ modified ,
832+ item . last_modified ,
833+ this . _modifiedStyle
834+ ) ;
835+ }
836+ } ) ;
837+ }
838+
824839 // Update item nodes based on widget state.
825840 protected updateNodes ( items : Contents . IModel [ ] , nodes : HTMLElement [ ] ) {
826841 items . forEach ( ( item , i ) => {
@@ -962,11 +977,11 @@ export class DirListing extends Widget {
962977 msg . width === - 1 ? this . node . getBoundingClientRect ( ) : msg ;
963978 this . toggleClass ( 'jp-DirListing-narrow' , width < 250 ) ;
964979
965- // Rerender item nodes, so that their modified dates update , if the modified style has changed.
980+ // Rerender item nodes' modified dates, if the modified style has changed.
966981 const oldModifiedStyle = this . _modifiedStyle ;
967982 this . updateModifiedSize ( this . node ) ;
968983 if ( oldModifiedStyle !== this . _modifiedStyle ) {
969- this . updateNodes ( this . _sortedItems , this . _items ) ;
984+ this . updateModified ( this . _sortedItems , this . _items ) ;
970985 }
971986 }
972987
@@ -2231,6 +2246,21 @@ export namespace DirListing {
22312246 hiddenColumns ?: Set < DirListing . ToggleableColumn >
22322247 ) : HTMLElement ;
22332248
2249+ /**
2250+ * Update an item's last modified date.
2251+ *
2252+ * @param modified - Element containing the file's last modified date.
2253+ *
2254+ * @param modifiedDate - String representation of the last modified date.
2255+ *
2256+ * @param modifiedStyle - The date style for the modified column: narrow, short, or long
2257+ */
2258+ updateItemModified (
2259+ modified : HTMLElement ,
2260+ modifiedDate : string ,
2261+ modifiedStyle : Time . HumanStyle
2262+ ) : void ;
2263+
22342264 /**
22352265 * Update an item node to reflect the current state of a model.
22362266 *
@@ -2557,6 +2587,31 @@ export namespace DirListing {
25572587 return labelWrapper ;
25582588 }
25592589
2590+ /**
2591+ * Update an item's last modified date.
2592+ *
2593+ * @param modified - Element containing the file's last modified date.
2594+ *
2595+ * @param modifiedDate - String representation of the last modified date.
2596+ *
2597+ * @param modifiedStyle - The date style for the modified column: narrow, short, or long
2598+ */
2599+ updateItemModified (
2600+ modified : HTMLElement ,
2601+ modifiedDate : string ,
2602+ modifiedStyle : Time . HumanStyle
2603+ ) : void {
2604+ let modText = '' ;
2605+ let modTitle = '' ;
2606+
2607+ // Render the date in one of multiple formats, depending on the container's size
2608+ modText = Time . formatHuman ( new Date ( modifiedDate ) , modifiedStyle ) ;
2609+ modTitle = Time . format ( new Date ( modifiedDate ) ) ;
2610+
2611+ modified . textContent = modText ;
2612+ modified . title = modTitle ;
2613+ }
2614+
25602615 /**
25612616 * Update an item node to reflect the current state of a model.
25622617 *
@@ -2694,18 +2749,9 @@ export namespace DirListing {
26942749 checkbox . checked = selected ?? false ;
26952750 }
26962751
2697- let modText = '' ;
2698- let modTitle = '' ;
26992752 if ( model . last_modified ) {
2700- // Render the date in one of multiple formats, depending on the container's size
2701- modText = Time . formatHuman (
2702- new Date ( model . last_modified ) ,
2703- modifiedStyle
2704- ) ;
2705- modTitle = Time . format ( new Date ( model . last_modified ) ) ;
2753+ this . updateItemModified ( modified , model . last_modified , modifiedStyle ) ;
27062754 }
2707- modified . textContent = modText ;
2708- modified . title = modTitle ;
27092755 }
27102756
27112757 /**
0 commit comments