commit 52c66446034d33a5b41671492d75d72c8c6b6a5f
parent 1732fe6724fcb0b43eb1735218cef27bb71c1c62
Author: Dão Gottwald <dao@mozilla.com>
Date: Wed, 7 Jan 2026 17:29:39 +0000
Bug 2007383 - Don't automatically submit when dropping on the search bar. r=mbeier,urlbar-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D278114
Diffstat:
1 file changed, 28 insertions(+), 13 deletions(-)
diff --git a/browser/components/urlbar/content/UrlbarInput.mjs b/browser/components/urlbar/content/UrlbarInput.mjs
@@ -5505,28 +5505,43 @@ export class UrlbarInput extends HTMLElement {
* @param {DragEvent} event
*/
_on_drop(event) {
- let droppedItem = getDroppableData(event);
- let droppedURL = URL.isInstance(droppedItem)
- ? droppedItem.href
- : droppedItem;
- if (droppedURL && droppedURL !== this.window.gBrowser.currentURI.spec) {
- let principal = Services.droppedLinkHandler.getTriggeringPrincipal(event);
- this.value = droppedURL;
+ let droppedData = getDroppableData(event);
+ let droppedString = URL.isInstance(droppedData)
+ ? droppedData.href
+ : droppedData;
+ if (
+ droppedString &&
+ droppedString !== this.window.gBrowser.currentURI.spec
+ ) {
+ this.value = droppedString;
this.setPageProxyState("invalid");
this.focus();
- // To simplify tracking of events, register an initial event for event
- // telemetry, to replace the missing input event.
- let queryContext = this.#makeQueryContext({ searchString: droppedURL });
- this.controller.setLastQueryContextCache(queryContext);
- this.controller.engagementEvent.start(event, queryContext);
- this.handleNavigation({ triggeringPrincipal: principal });
if (this.#isAddressbar) {
+ // If we're an address bar, we automatically open the dropped address or
+ // submit the dropped string to the search engine.
+ let principal =
+ Services.droppedLinkHandler.getTriggeringPrincipal(event);
+ // To simplify tracking of events, register an initial event for event
+ // telemetry, to replace the missing input event.
+ let queryContext = this.#makeQueryContext({
+ searchString: droppedString,
+ });
+ this.controller.setLastQueryContextCache(queryContext);
+ this.controller.engagementEvent.start(event, queryContext);
+ this.handleNavigation({ triggeringPrincipal: principal });
// For safety reasons, in the drop case we don't want to immediately show
// the dropped value, instead we want to keep showing the current page
// url until an onLocationChange happens.
// See the handling in `setURI` for further details.
this.userTypedValue = null;
this.setURI({ dueToTabSwitch: true });
+ } else {
+ // If we're a search bar, allow for getting search suggestions, changing
+ // the search engine, or modifying the search term before submitting.
+ this.startQuery({
+ searchString: droppedString,
+ event,
+ });
}
}
}