Closed Bug 1779469 Opened 3 years ago Closed 1 year ago

Modify UrlbarInput’s clipboard behavior so that the URL is copied when the search terms are unmodified

Categories

(Firefox :: Address Bar, task, P3)

task

Tracking

()

RESOLVED INVALID

People

(Reporter: jteow, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 obsolete file)

No description provided.
Depends on: 1779465

:adw, out of curiosity, I was investigating this feature a bit more.

One way of doing this is creating a flag that becomes true if we are focusing the Urlbar for the first time. Here are ways I can think of where the Urlbar can get focused:

  • Clicks on the urlbar
  • Use tab to focus the urlbar
  • Use a keyboard shortcut (Command + l)
  • Some process calls Urlbar.focus()

From there, we could add a flag like firstTimeSelectingAll which could be checked in _getSelectedValueForClipboard.

However, it doesn't seem trivial to reason where and when to turn on/turn off this flag.

Perhaps the better way to address this potential issue is by adding another option in the context menu, something like like "Copy URL"? And it only shows up if the search terms are enabled, the entire string is highlighted, and the search terms are currently showing in the Urlbar.

Flags: needinfo?(adw)

Actually, a solution might be based on the fact that anytime the urlbar is focused, select will fire because focusing the urlbar will select all the text.

Here are two flags:

  • copySearchTerms
  • notFocusedSinceLastBlur

In select add a check to see if the full search term is showing, all the characters are highlighted and if we haven't highlighted all the characters yet since the last blur event (notFocusedSinceLastBlur).

  • If all true, set notFocusedSinceLastBlur to false and copySearchTerms to true
  • Otherwise, set copySearchTerms should to false

On blur event, copySearchTerms should be false and notFocusedSinceLastBlur should be true

Then in _getSelectedValueForClipboard, check if that copySearchTerms is true. If it is, don't use the userTypedValue for the clipboard, use the URI.

(In reply to James Teow [:jteow] from comment #2)

However, it doesn't seem trivial to reason where and when to turn on/turn off this flag.

Yeah, exactly, IMO we need to really think twice before we start adding more state. But say we had firstTimeSelectingAll and it worked perfectly -- what would that enable us to do? Would we want to copy the URL only when firstTimeSelectingAll is true? Why?

And to your comment 3 too, IMO it's not important whether the urlbar was focused since last blur or whether it's the first time selecting all. The urlbar already has a custom copy controller with most of the work happening in UrlbarInput._getSelectedValueForClipboard(). One of the things that method handles is that, when you visit an http page (not https) like http://example.com/, the urlbar shows "example.com", but when the selection contains the entire string and you copy, the full URL ends up on your clipboard. We would handle search terms the same way.

Maybe that actually would not be hard to implement now that we have showingSearchTerms? You could try modifying that method with something like:

if (
  this.value == selectedVal &&
  this.window.gBrowser.selectedBrowser.showingSearchTerms
) {
  return displaySpec;
}

It might be more complex than that, not sure.

Perhaps the better way to address this potential issue is by adding another option in the context menu, something like like "Copy URL"? And it only shows up if the search terms are enabled, the entire string is highlighted, and the search terms are currently showing in the Urlbar.

I kind of like this. It seems like it would satisfy the kinds of people who would get upset by not having absolute control over what gets copied in this case -- although they might still be upset they can't just Ctrl+C, so maybe not. I think it's worth mentioning to Henry as a possibility, but I'm not totally convinced it's worth the extra complexity.

Flags: needinfo?(adw)

But say we had firstTimeSelectingAll and it worked perfectly -- what would that enable us to do? Would we want to copy the URL only when firstTimeSelectingAll is true? Why?

Yes, that's the idea, it's so that users can still have the ability to copy the entire search term as opposed to only allowing them to copy the URL when the entire string is selected. We could teach them that upon the first select all, we copy the URL, but any modifications (including selecting all again while the urlbar is focused) after that we respect your selection and copy the search terms.

Attachment #9290701 - Attachment is obsolete: true

Closing as this is not a direction we want to do.

Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: