Open Bug 1816870 Opened 2 years ago Updated 1 year ago

Context menu API: White space is collapsed in menu items

Categories

(WebExtensions :: Frontend, defect, P3)

defect

Tracking

(firefox-esr102 unaffected, firefox110 wontfix, firefox111 wontfix, firefox112 wontfix)

Tracking Status
firefox-esr102 --- unaffected
firefox110 --- wontfix
firefox111 --- wontfix
firefox112 --- wontfix

People

(Reporter: tdulcet, Unassigned)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

Attached image image.png

Steps to reproduce:

  1. Create a context menu item with lots of white space:
browser.menus.create({
  title: "       lots       of       white       space       "
});

Expected result:
White space is preserved.

Actual result:
White space is collapsed.

This worked as expected in Firefox 108 and before, but broke in Firefox 109. Regression range from mozregression: https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=efbd04cb07486419679cf588ba6095f7ef9edef6&tochange=439eb32c377831956882142acdc81b182ba2145b. Bug 1799460 looks most likely. Another regression of that is bug 1801172, which is very similar to this.

The attached screenshot is from my Link Creator add-on, which uses leading white space to indent some menu items for readability.

Keywords: regression
Regressed by: 1799460

Set release status flags based on info from the regressing bug 1799460

:emilio, since you are the author of the regressor, bug 1799460, could you take a look? Also, could you set the severity field?

For more information, please visit auto_nag documentation.

It shouldn't be collapsed if you use non-breaking spaces right? So, " in New Tab".replaceAll(" ", "\xa0"); or so.

This seems slightly tricky to fix, because we really want these not to wrap (and unlike the bookmark items which can't have newlines, these can), and to crop the end if they are too long, and there's no easy way in CSS to do "don't break newlines, but preserve spaces". We could implement a hack to replace spaces for non breaking spaces internally, but I'd rather not.

So I'd prefer to keep the current behavior, if using non-breaking spaces is a possibility?

Flags: needinfo?(emilio) → needinfo?(tdulcet)
See Also: → 1816899

I just realized that css-text-4 would provide a way of doing this, filed bug 1816899 to track that. But for now non-breaking spaces would be preferable (and more future-proof).

I guess we could also do this at the web-extensions API level (doing something like that replaceAll...). If you insist I might go for that solution for now.

(In reply to Emilio Cobos Álvarez (:emilio) from comment #2)

It shouldn't be collapsed if you use non-breaking spaces right? So, " in New Tab".replaceAll(" ", "\xa0"); or so.

Yes, I just updated my local copy of the extension to use non-breaking spaces and it does now seem to work as expected. However, this is still a regression in behavior from all previous versions of Firefox (from before 109) and is likely breaking other add-ons. It is also now a difference in behavior from Chrome.

I guess we could also do this at the web-extensions API level (doing something like that replaceAll...).

Add-ons might be using white space characters other than a space (i.e. a tab), so maybe something like this instead:
.replaceAll(/\s/ug, "\u00A0").

Flags: needinfo?(tdulcet)
Severity: -- → S4
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: