mirror of
				https://github.com/searxng/searxng.git
				synced 2025-11-03 19:17:07 -05:00 
			
		
		
		
	[feat] client/simple: move cursor to end of search input on mobile
On mobile devices, when the search input is focused, move the cursor to the end of the existing text. This improves the user experience by making it easier to edit or append to the current query without manually moving the cursor first. Closes: https://github.com/searxng/searxng/issues/5112
This commit is contained in:
		
							parent
							
								
									22c2c93274
								
							
						
					
					
						commit
						5ca70ca17e
					
				@ -40,6 +40,18 @@ if (!(isMobile || isResultsPage)) {
 | 
			
		||||
  qInput.focus();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// On mobile, move cursor to the end of the input on focus
 | 
			
		||||
if (isMobile) {
 | 
			
		||||
  listen("focus", qInput, () => {
 | 
			
		||||
    // Defer cursor move until the next frame to prevent a visual jump
 | 
			
		||||
    requestAnimationFrame(() => {
 | 
			
		||||
      const end = qInput.value.length;
 | 
			
		||||
      qInput.setSelectionRange(end, end);
 | 
			
		||||
      qInput.scrollLeft = qInput.scrollWidth;
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
createClearButton(qInput);
 | 
			
		||||
 | 
			
		||||
// Additionally to searching when selecting a new category, we also
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user