mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	compose: Fix using Up when editing messages.
This fixes a very noticable regression in
92788a52bb, where using Up/PageUp/Home
when focus was in anything other than the compose box would
incorrectly be treated as message feed navigation.
Fix this by adding a new check, but this now has some fairly
duplicated code that queries the DOM for the same thing 3 times in a
row; added a TODO comment explaining a likely better approach.
			
			
This commit is contained in:
		@@ -71,6 +71,14 @@ export const message_content = get_or_set("compose-textarea", true);
 | 
				
			|||||||
const untrimmed_message_content = get_or_set("compose-textarea", true, true);
 | 
					const untrimmed_message_content = get_or_set("compose-textarea", true, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function cursor_at_start_of_whitespace_in_compose() {
 | 
					export function cursor_at_start_of_whitespace_in_compose() {
 | 
				
			||||||
 | 
					    // First check if the compose box is focused.  TODO: Maybe we
 | 
				
			||||||
 | 
					    // should make `consider_start_of_whitespace_message_empty` a
 | 
				
			||||||
 | 
					    // parameter to `focus_in_empty_compose` instead.
 | 
				
			||||||
 | 
					    const focused_element_id = document.activeElement.id;
 | 
				
			||||||
 | 
					    if (focused_element_id !== "compose-textarea") {
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const cursor_position = $("#compose-textarea").caret();
 | 
					    const cursor_position = $("#compose-textarea").caret();
 | 
				
			||||||
    return message_content() === "" && cursor_position === 0;
 | 
					    return message_content() === "" && cursor_position === 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user