Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date Input has incorrect sizing in Safari #34433

Closed
stephenreay opened this issue Jul 6, 2021 · 7 comments · Fixed by #37350
Closed

Date Input has incorrect sizing in Safari #34433

stephenreay opened this issue Jul 6, 2021 · 7 comments · Fixed by #37350

Comments

@stephenreay
Copy link
Contributor

In Safari 14.1 (on macOS Big Sur) the following will render 'incorrectly' on Safari - the date input element is over-sized.

The issue isn't related to having another column or another field - but having a regular text input helps to highlight the sizing bug.

FF seems to render it correctly.

<div class="container">
<div class="row g-3">
  <div class="col">
    <input type="text" class="form-control" placeholder="First name" aria-label="First name">
  </div>
  <div class="col">
    <input type="date" class="form-control"">
  </div>
</div>
</div>
@ffoodd
Copy link
Member

ffoodd commented Jul 7, 2021

Made a reduced test case on CodePen so I can confirm with BrowserStack:
bs_macbsr_Safari_14 0

I'm unable to find out what's happening here, for now.

@stephenreay
Copy link
Contributor Author

stephenreay commented Jul 7, 2021

I did some digging before filing the issue, it's quite bizarre to me (but CSS isn't really my regular gig). The shadow DOM for browser-defined parts of the element don't show as having the extra space (although they do have white-space: pre rules) - there's just this mysterious extra spacing below it.

Screenshots from Safari inspector showing the details for the input and the root div inside the shadow DOM. Let me know if there's any more info/tests/debugging I can help with from a 'real' safari.

The input itself:
Screen Shot 2021-07-07 at 19 43 41

The shadow dom root div:
Screen Shot 2021-07-07 at 19 43 52

@stephenreay
Copy link
Contributor Author

Updated demo on codepen (previous one has a broken CSS link)

https://codepen.io/stephenreay/pen/ExbWoRz

@stephenreay
Copy link
Contributor Author

Doing some digging, the trigger for this is the display: block rule on the input element.

I've filed a webkit bug about this: https://bugs.webkit.org/show_bug.cgi?id=236352

@mdo
Copy link
Member

mdo commented Apr 8, 2022

This one is super rough because the display: block makes it worse, but it's not the only issue at play. Plus, the styles are inconsistent between Chrome and Safari, so it's unclear how we could make this 100% consistent between browsers. We even had issues in the past when using a fixed height.

@javierartero
Copy link

javierartero commented Aug 31, 2022

This can be fixed from the webkit pseudo-element ::-webkit-datetime-edit

input::-webkit-datetime-edit {
  display: block;
  padding: 0;
}

stephenreay added a commit to Koalephant/bootstrap that referenced this issue Oct 21, 2022
mdo pushed a commit that referenced this issue Oct 30, 2022
* Prevent extraneous whitespace around date time inputs in Webkit

Closes #34433

* Updated bundlewatch config
@x-adri-x
Copy link

This can be fixed from the webkit pseudo-element ::-webkit-datetime-edit

input::-webkit-datetime-edit {
  display: block;
  padding: 0;
}

Now, this worked like magic! Thank you so much, Safari was really ruining my day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants