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

How to make Calendar icon show in React Date Picker? #4291

Closed
AtGbemiga opened this issue Oct 6, 2023 · 10 comments
Closed

How to make Calendar icon show in React Date Picker? #4291

AtGbemiga opened this issue Oct 6, 2023 · 10 comments

Comments

@AtGbemiga
Copy link

AtGbemiga commented Oct 6, 2023

Describe the bug
I'm using React Date Picker, which I installed via npm i react-datepicker. Everything works except the calendar icon which doesn't display. The docs says to add showIcon to the JSX element to display the calendar icon, this does not show the icon, it only makes the JSX element bigger.

To Reproduce

"use client";

import { useState } from "react";
import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";


export default function Form() {
  const [dateRange, setDateRange] = useState<[Date | null, Date | null]>([
    null,
    null,
  ]);
  const [startDate, endDate] = dateRange;

  return (
    <form>
      <DatePicker
        showIcon
        selectsRange={true}
        startDate={startDate}
        endDate={endDate}
        onChange={(update) => {
          console.log("Selected Date Range:", update);
          setDateRange(update);
        }}
        minDate={new Date()}
        withPortal
      />
    </form>
  );
}

Expected behavior
A calendar icon should be displayed.

Screenshots
No icon

Desktop (please complete the following information):

  • OS: Windows
  • Browser chrome
  • Version "^4.16.0"
@franmc01
Copy link
Contributor

franmc01 commented Oct 7, 2023

@AtGbemiga show #4295

@AtGbemiga
Copy link
Author

@AtGbemiga show #4295

I don't understand what your response is stating.

@franmc01
Copy link
Contributor

franmc01 commented Oct 8, 2023

Try the last versión and if problem persist please added a Sanbox or Stackblitz :)

@AtGbemiga
Copy link
Author

Try the last versión and if problem persist please added a Sanbox or Stackblitz :)

Alright, I will as quickly as possible :)

@skoldborg
Copy link

I can confirm that showIcon is not working and neither is the new icon prop. I'm using the latest version (4.19.0).

I created a StackBlitz project for reference:
https://stackblitz.com/edit/stackblitz-starters-rne2cz?file=src%2FApp.tsx

@franmc01
Copy link
Contributor

franmc01 commented Oct 9, 2023

Hey bro, you know, check it out and see if it's true. But the problem is more than anything because of a style:

After
image

Before
image

I'm going to review and look for the cause, because analyzing X's comment, this came from the last version. The funniest thing is that he never replied to me

@skoldborg
Copy link

@frankops11 Overriding box-sizing: border-box; does indeed solve the issue, but I'm not sure that's a viable solution? Icon should be still be visible when box-sizing: border-box; is set, no?

@franmc01
Copy link
Contributor

franmc01 commented Oct 9, 2023

That's right, I should be indifferent, I already have a solution and I'm raising the PR

franmc01 added a commit to franmc01/react-datepicker that referenced this issue Oct 9, 2023
martijnrusschen added a commit that referenced this issue Oct 9, 2023
Fix: Display Issue of Calendar Icon in React Date Picker (#4291)
@franmc01
Copy link
Contributor

franmc01 commented Oct 9, 2023

Hello Everyone! 🚀

Thrilled to announce that the solution to the calendar icon issue has been merged into the main branch! 🎉 Therefore, we can confidently state that issue #4291 is officially resolved.

The update will be available to all in the next release! We greatly appreciate your patience and constructive contributions throughout this resolution process. Your feedback and collaboration have been instrumental in reaching this juncture, and we’re excited to bring this enhancement to you all.

Warm regards

@AtGbemiga
Copy link
Author

I can confirm that the issue is fixed.
version: "^4.20.0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants