Moved search dialog rendering code to its own function.