diff --git a/ios/chrome/browser/web/model/choose_file/choose_file_tab_helper.mm b/ios/chrome/browser/web/model/choose_file/choose_file_tab_helper.mm index 5ad4eb71d6a0e..8671a8a00fa07 100644 --- a/ios/chrome/browser/web/model/choose_file/choose_file_tab_helper.mm +++ b/ios/chrome/browser/web/model/choose_file/choose_file_tab_helper.mm @@ -231,11 +231,15 @@ void ChooseFileTabHelper::DidStartNavigation( web::NavigationContext* navigation_context) { if (!navigation_context->IsSameDocument()) { AbortSelection(); + // Do not let a ChooseFileEvent posted by the previous document leak into + // the next document's RunOpenPanel call. + last_choose_file_event_.reset(); } } void ChooseFileTabHelper::WasHidden(web::WebState* web_state) { AbortSelection(); + last_choose_file_event_.reset(); } void ChooseFileTabHelper::WebStateDestroyed(web::WebState* web_state) {