Closed Bug 2015071 Opened 6 months ago Closed 4 months ago

Tab notes should not be saved when input contains only spaces

Categories

(Firefox :: Tabbed Browser, defect, P2)

Firefox 149
Desktop
All
defect
Points:
1

Tracking

()

RESOLVED FIXED
151 Branch
Tracking Status
firefox149 --- wontfix
firefox150 --- wontfix
firefox151 --- fixed

People

(Reporter: rpopovici, Assigned: chimaifeanyi29, Mentored)

References

(Blocks 2 open bugs)

Details

(Keywords: good-first-bug, Whiteboard: [fidefe-tabgrps][outreachy-sidebar-2026])

Attachments

(2 files)

Note

  • The user should not be able to save a note when input contains only space(s). This could be an improvement.

Found in

  • Nightly v149.0a1

Affected versions

  • Nightly v149.0a1

Tested platforms

  • Affected platforms: all
  • Unaffected platforms: none

Steps to reproduce

  1. Load any website
  2. Right-click to add a note
  3. Press the "Space" key and save the note
  4. Hover the tab and observe the note

Expected result

  • Tab notes should not be saved when input contains only space(s).

Actual result

  • An empty note is displayed on hovering.

Regression range

  • Not a regression.
No longer blocks: tab-notes
Has STR: --- → yes
QA Whiteboard: [QA-4574][qa-found-in-c149][S3]
No longer depends on: 2009426
Version: Firefox 148 → Firefox 149
Blocks: tab-notes
Type: defect → enhancement

I believe our spec indicated that tab notes should not be saved when the text is empty, so I consider this a bug. Thank you.

Severity: -- → S3
Type: enhancement → defect
Points: --- → 1
Priority: -- → P2

In the following two places, we check the length of the text in the note textarea in order to determine whether to allow a note to be saved:

  1. https://searchfox.org/firefox-main/rev/1427c88632d1474d2653928745d78feca1a64ee0/browser/components/tabbrowser/content/tabnote-menu.js#179-190 to disable the "Save" button when note text is empty
  2. https://searchfox.org/firefox-main/rev/1427c88632d1474d2653928745d78feca1a64ee0/browser/components/tabbrowser/content/tabnote-menu.js#261 to skip saving a note if the note text is empty

In both of these cases, if the note text is " " (5 spaces), then the note will be saved. However, we do not want to save empty notes!

Instead of using the character count of the textarea element as this.#noteField.value.length, we should use the character count of the textarea element after trimming beginning and ending whitespace from the text. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim is a built-in way to trim whitespace from a string value.

We should add a new test case next to this existing test https://searchfox.org/firefox-main/rev/1427c88632d1474d2653928745d78feca1a64ee0/browser/components/tabnotes/test/browser/browser_tab_notes_menu.js#354-396 When the note textarea contains only whitespace (spaces, newlines, etc.) then the Save button should be disabled.

Keywords: good-first-bug

Hi, please choose me

Assignee: nobody → chimaifeanyi29
Status: NEW → ASSIGNED

my first bug please !!

Whiteboard: [fidefe-tabgrps] → [fidefe-tabgrps][outreachy-sidebar-2026]
Pushed by nsharpley@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/526ca6df071b https://hg.mozilla.org/integration/autoland/rev/dd5e80fd37f4 Do not save tab note when input contains only whitespace. r=tabbrowser-reviewers,nsharpley
Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 151 Branch

Since nightly and release are affected, beta will likely be affected too.
For more information, please visit BugBot documentation.

The patch landed in nightly and beta is affected.
:chimaifeanyi29, is this bug important enough to require an uplift?

For more information, please visit BugBot documentation.

Flags: needinfo?(chimaifeanyi29)

Checking with :sthompson on if this should be uplifted to beta or not

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

Attachment

General

Created:
Updated:
Size: