Fix directory scroll position reset (#34560)
This commit is contained in:
		
					parent
					
						
							
								05f6f7d28a
							
						
					
				
			
			
				commit
				
					
						e3f0b955b8
					
				
			
		
					 2 changed files with 17 additions and 4 deletions
				
			
		|  | @ -1,24 +1,32 @@ | |||
| import { FormattedMessage } from 'react-intl'; | ||||
| 
 | ||||
| import { LoadingIndicator } from './loading_indicator'; | ||||
| 
 | ||||
| interface Props { | ||||
|   onClick: (event: React.MouseEvent) => void; | ||||
|   disabled?: boolean; | ||||
|   visible?: boolean; | ||||
|   loading?: boolean; | ||||
| } | ||||
| export const LoadMore: React.FC<Props> = ({ | ||||
|   onClick, | ||||
|   disabled, | ||||
|   visible = true, | ||||
|   loading = false, | ||||
| }) => { | ||||
|   return ( | ||||
|     <button | ||||
|       type='button' | ||||
|       className='load-more' | ||||
|       disabled={disabled || !visible} | ||||
|       disabled={disabled || loading || !visible} | ||||
|       style={{ visibility: visible ? 'visible' : 'hidden' }} | ||||
|       onClick={onClick} | ||||
|     > | ||||
|       <FormattedMessage id='status.load_more' defaultMessage='Load more' /> | ||||
|       {loading ? ( | ||||
|         <LoadingIndicator /> | ||||
|       ) : ( | ||||
|         <FormattedMessage id='status.load_more' defaultMessage='Load more' /> | ||||
|       )} | ||||
|     </button> | ||||
|   ); | ||||
| }; | ||||
|  |  | |||
|  | @ -130,6 +130,7 @@ export const Directory: React.FC<{ | |||
|   }, [dispatch, order, local]); | ||||
| 
 | ||||
|   const pinned = !!columnId; | ||||
|   const initialLoad = isLoading && accountIds.size === 0; | ||||
| 
 | ||||
|   const scrollableArea = ( | ||||
|     <div className='scrollable'> | ||||
|  | @ -170,7 +171,7 @@ export const Directory: React.FC<{ | |||
|       </div> | ||||
| 
 | ||||
|       <div className='directory__list'> | ||||
|         {isLoading ? ( | ||||
|         {initialLoad ? ( | ||||
|           <LoadingIndicator /> | ||||
|         ) : ( | ||||
|           accountIds.map((accountId) => ( | ||||
|  | @ -179,7 +180,11 @@ export const Directory: React.FC<{ | |||
|         )} | ||||
|       </div> | ||||
| 
 | ||||
|       <LoadMore onClick={handleLoadMore} visible={!isLoading} /> | ||||
|       <LoadMore | ||||
|         onClick={handleLoadMore} | ||||
|         visible={!initialLoad} | ||||
|         loading={isLoading} | ||||
|       /> | ||||
|     </div> | ||||
|   ); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue