Closed Bug 838705 Opened 12 years ago Closed 12 years ago

Show the file names or "No file selected" in tooltip

Categories

(Firefox :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 22

People

(Reporter: mounir, Assigned: mounir)

References

Details

Attachments

(2 files, 2 obsolete files)

Attached patch Patch (obsolete) — Splinter Review
No description provided.
Attachment #710796 - Flags: review?(ttaubert)
Comment on attachment 710796 [details] [diff] [review] Patch Review of attachment 710796 [details] [diff] [review]: ----------------------------------------------------------------- I like the idea and think this is indeed a useful thing to have, especially if the file path is really long and you're not totally sure you attached the right file. ::: browser/base/content/browser.js @@ +2953,5 @@ > + tipElement.type == 'file' && > + !tipElement.hasAttribute('title')) { > + let files = tipElement.files; > + > + if (files.length == 0) { The file input field might be "required" and |titleText| might have already been filled with the .validationMessage. We should not overwrite it and check that |titleText| is empty. @@ +2961,5 @@ > + } else { > + titleText = bundle.GetStringFromName("NoFileSelected"); > + } > + } else if (files.length == 1) { > + titleText = files[0].name; We don't really need that branch as it's covered by the one below.
Attachment #710796 - Flags: review?(ttaubert) → feedback+
Attached patch Patch v2 (obsolete) — Splinter Review
Attachment #710803 - Flags: review?(ttaubert)
Attachment #710796 - Attachment is obsolete: true
(In reply to Tim Taubert [:ttaubert] from comment #1) > Comment on attachment 710796 [details] [diff] [review] > Patch > > Review of attachment 710796 [details] [diff] [review]: > ----------------------------------------------------------------- > > I like the idea and think this is indeed a useful thing to have, especially > if the file path is really long and you're not totally sure you attached the > right file. Thanks for those comments :) The change is actually part of a bigger change in <input type='file'> (see bug 838675). Hopefully, we will no longer be ashamed by our <input type='file'> implementation :)
Comment on attachment 710803 [details] [diff] [review] Patch v2 Review of attachment 710803 [details] [diff] [review]: ----------------------------------------------------------------- ::: browser/base/content/browser.js @@ +2957,5 @@ > + > + if (files.length == 0) { > + var bundle = Services.strings.createBundle("chrome://global/locale/layout/HtmlForm.properties"); > + if (tipElement.multiple) { > + titleText = bundle.GetStringFromName("NoFilesSelected"); Seems like these strings don't exist in HtmlForm.properties, yet. These lines throw errors and cause old tooltips to be displayed.
Attachment #710803 - Flags: review?(ttaubert)
Comment on attachment 710803 [details] [diff] [review] Patch v2 Those strings are added by bug 345195. The changes in <input type='file'> are a long patch queue. Let me know if you want to actually test the change.
Attachment #710803 - Flags: review?(ttaubert)
Comment on attachment 710803 [details] [diff] [review] Patch v2 Review of attachment 710803 [details] [diff] [review]: ----------------------------------------------------------------- Ok, I tested the patch with other existing strings and it works fine. This then needs to wait for bug 345195 to land. ::: browser/base/content/browser.js @@ +2957,5 @@ > + > + if (files.length == 0) { > + var bundle = Services.strings.createBundle("chrome://global/locale/layout/HtmlForm.properties"); > + if (tipElement.multiple) { > + titleText = bundle.GetStringFromName("NoFilesSelected"); Seems like these strings don't exist in HtmlForm.properties, yet. These lines throw errors and cause old tooltips to be displayed.
Attachment #710803 - Flags: review?(ttaubert) → review+
Attached patch Patch with testsSplinter Review
Tim, feel free to review the tests. Most ppl don't want to do that so I will not formally ask for a review.
Attachment #710803 - Attachment is obsolete: true
(In reply to Mounir Lamouri (:mounir) from comment #7) > Tim, feel free to review the tests. Most ppl don't want to do that so I will > not formally ask for a review. Seriously? I'm fine with only skimming a test but not reviewing at all seems strange to me. I'll do that of course if you include the file in the patch ;)
Attached patch PatchSplinter Review
Attachment #711325 - Flags: review?(ttaubert)
Comment on attachment 711325 [details] [diff] [review] Patch Review of attachment 711325 [details] [diff] [review]: ----------------------------------------------------------------- ::: browser/base/content/test/browser_input_file_tooltips.js @@ +12,5 @@ > + let tooltip = document.getElementById("aHTMLTooltip"); > + > + for (let test of data) { > + let input = doc.createElement('input'); > + doc.body.appendChild(input); Should we care about removing those elements afterwards?
Attachment #711325 - Flags: review?(ttaubert) → review+
I do not think that is needed.
Target Milestone: --- → Firefox 22
> + var bundle = Services.strings.createBundle("chrome://global/locale/layout/HtmlForm.properties"); 'Services' hasn't been imported here. This should probably just get the service directly. Also, this would be better wrapped in a try/catch block.
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Depends on: 855657
Depends on: 1251809
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: