bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Date Input has incorrect sizing in Safari

Open stephenreay opened this issue 3 years ago • 6 comments

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>

stephenreay avatar Jul 06 '21 12:07 stephenreay

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.

ffoodd avatar Jul 07 '21 12:07 ffoodd

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 avatar Jul 07 '21 12:07 stephenreay

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

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

stephenreay avatar Feb 09 '22 08:02 stephenreay

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

stephenreay avatar Feb 09 '22 08:02 stephenreay

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.

mdo avatar Apr 08 '22 21:04 mdo

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

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

javierartero avatar Aug 31 '22 11:08 javierartero

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.

x-adri-x avatar Nov 29 '23 08:11 x-adri-x