Closed Bug 1714631 Opened 3 years ago Closed 3 years ago

Misaligned input placeholder

Categories

(Core :: Layout: Form Controls, defect)

Firefox 89
defect

Tracking

()

RESOLVED FIXED
91 Branch
Tracking Status
firefox91 --- fixed

People

(Reporter: leobasilio, Assigned: emilio)

References

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0

Steps to reproduce:

Today my Firefox was updated to version 89.0. I see there's a new implementation for web forms. See the attached screenshot.

Actual results:

The placeholder is aligned to the top (first field) while the text content (second field) is correctly aligned to the center.

Expected results:

Both placeholder and content should align to the center. The same code works fine on Chrome.

The Bugbug bot thinks this bug should belong to the 'Core::Layout: Form Controls' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → Layout: Form Controls
Product: Firefox → Core

Can you link to that site or attach an HTML file that repros the issue? Thanks!

Flags: needinfo?(leobasilio)
Attached file form.html
Flags: needinfo?(leobasilio)

That's not my code, and as I was trimming it down to post here I realized they used a "input::placeholder" selector to style the placeholder. If we remove "line-height: 22px;" from this selector, then the placeholder is correctly aligned. I don't know what should be the expected behavior, but the point is that the text content and the placeholder don't seem to be following the same positioning rules.

Thanks, that's very useful. This is because the placeholder is an internal element to the <input> (you can see this if you go to about:config and change devtools.inspector.showAllAnonymousContent=true), which by default has line-height: -moz-block-height. The code here is overriding it with a line-height value which is different, which causes the positioning issue.

This doesn't seem like a recent regression... Perhaps we could consider making this rule important, as other browsers also don't seem to allow you to change the line-height of the ::placeholder (or at least in Chrome if I set 50px or something the rendering is the same).

Assignee: nobody → emilio
Severity: -- → S3
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1a2b6b35c69b
Make input placeholder line-height declaration important, to match other engines. r=jwatt
Pushed by emilio@crisal.io:
https://hg.mozilla.org/integration/autoland/rev/012f302cf03b
Fix test_placeholder_restrictions.html
Pushed by emilio@crisal.io:
https://hg.mozilla.org/integration/autoland/rev/3571fd3cb3bc
Move an NS_ASSERTION to the right place so it doesn't fire incorrectly.
Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 91 Branch
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/29252 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot
Duplicate of this bug: 1068856
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: