move dialog before elements with template params