Open Bug 1763744 Opened 3 years ago Updated 3 years ago

text inside button can't be selected by "Select All"

Categories

(Core :: DOM: Selection, defect)

defect

Tracking

()

Webcompat Priority P3

People

(Reporter: karlcow, Unassigned)

References

Details

Attachments

(1 file)

Attached file testcase

Maybe this is normal by design, but there is a difference in behavior with Blink and WebKit.

  • TODO: check the spec.

This was initially reported on https://github.com/webcompat/web-bugs/issues/102132
But this is not specific to any sites in particular as it is happening everywhere. This is a difference of behavior. I didn't find a previous CLOSED bug for this. I was slightly surprised. It doesn't break the site, just change the user expectation with regards to copy and paste. as shown in the webcompat bug.

Steps to reproduce

  1. Open the testcase
  2. Select All

Note:

  • On Blink and WebKit, the text outside and inside the button is selected.
  • On Gecko, only the text outside the button is selected.

Buttons have user-select: none. It seems to come from bug 38506.

See Also: → 38506
Severity: -- → S3
Webcompat Priority: ? → P3

If user-select is specified, the result of <button> is same between Gecko and Blink.
https://jsfiddle.net/d_toybox/95wjyLp3/

Summary: text inside button can't be selected → text inside button can't be selected by "Select All"
<span style="user-select:none">
  <span style="user-select:text">
    text
  </span>
</span>

This code makes the "text" is always selectable, not only by "Select All", so if we need to fix this bug, we need tricky code for <button> element.

Two bugs have been recently opened on WebKit and Blink
https://bugs.webkit.org/show_bug.cgi?id=244448
https://bugs.chromium.org/p/chromium/issues/detail?id=1356522

I wonder if a spec issue would be a better place to resolve this.

What is the tricky part here? We have https://searchfox.org/mozilla-central/rev/380fc5571b039fd453b45bbb64ed13146fe9b066/layout/style/res/forms.css#509
Don't we get similar behavior to blink if we just remove that?

(But I'm not sure we want to get the same behavior as in blink)

Flags: needinfo?(masayuki)

(In reply to Olli Pettay [:smaug][bugs@pettay.fi] from comment #6)

What is the tricky part here? We have https://searchfox.org/mozilla-central/rev/380fc5571b039fd453b45bbb64ed13146fe9b066/layout/style/res/forms.css#509
Don't we get similar behavior to blink if we just remove that?

Once we make <button> has user-select: text (data:text/html,<button style="user-select:text">abc</button>), user can select text with both dragging in the button and "select all". However, Chrome allows only "select all" case, i.e., not allowing users to select button's text with dragging in the text. As far as I know, we don't have the code.

Therefore, I think that we need special handling around here and make <button> keep having user-select: none.

Flags: needinfo?(masayuki)

But in Chrome one can select the text by starting to drag outside the button. It seems that they just consume the mousedown or such event when it occurs on a button element and thus selection doesn't start.

Oh, good point. That sounds what Chrome does. (But I'm also not sure whether we should follow it.)

The example above https://drafts.csswg.org/css-ui/#issue-5d851d49 defines as:

The following additions are made to the UA stylesheet for HTML:
button, meter, progress, select { user-select: none; }
ISSUE 4: the list above is incomplete and needs to include at least the various button-like variants of input.

The severity field for this bug is relatively low, S3. However, the bug has 6 See Also bugs.
:peterv, could you consider increasing the bug severity?

For more information, please visit auto_nag documentation.

Flags: needinfo?(peterv)
Flags: needinfo?(peterv)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: