I finally figured out the problem and it was nothing related to the template files.
I had dequeue jquery and instead re-enqueued my custom jquery
as Jquery
instead of jquery
which is used by Elementor and that was the cause of the issue.
This is how my code was.
wp_dequeue_script('jquery');
wp_deregister_script('jquery');
wp_register_script('Jquery', get_template_directory_uri().'/vendor/jquery/jquery.js', false, '3.4.1', false);
wp_enqueue_script('Jquery');
this I was my fix
wp_dequeue_script('jquery');
wp_deregister_script('jquery');
wp_register_script('jquery', get_template_directory_uri().'/vendor/jquery/jquery.js', false, '3.4.1', false);
wp_enqueue_script('jquery');