TootBottomSheet: scrollIntoView exactly once
This commit is contained in:
		
							parent
							
								
									8c5ffc0f6b
								
							
						
					
					
						commit
						4cf64eae11
					
				
					 1 changed files with 4 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -80,11 +80,12 @@ const TootBottomSheet: Component = (props) => {
 | 
			
		|||
 | 
			
		||||
  const toot = () => remoteToot() ?? getCache(acctText(), params.id);
 | 
			
		||||
 | 
			
		||||
  createEffect(() => {
 | 
			
		||||
  createEffect((lastTootId?: string) => {
 | 
			
		||||
    const tootId = toot()?.id;
 | 
			
		||||
    if (!tootId) return;
 | 
			
		||||
    if (!tootId || lastTootId === tootId) return tootId;
 | 
			
		||||
    const elementId = `toot-${tootId}`;
 | 
			
		||||
    document.getElementById(elementId)?.scrollIntoView({ behavior: "smooth" });
 | 
			
		||||
    return tootId;
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  const [tootContext] = createResource(
 | 
			
		||||
| 
						 | 
				
			
			@ -109,7 +110,7 @@ const TootBottomSheet: Component = (props) => {
 | 
			
		|||
      const name = resolveCustomEmoji(t.account.displayName, t.account.emojis);
 | 
			
		||||
      return `${name}'s toot`;
 | 
			
		||||
    }
 | 
			
		||||
    return "A toot";
 | 
			
		||||
    return "Someone's toot";
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  const actSession = () => {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue