Skip to content

Add props to pass id and name attributes to the <input> #41

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

Merged
merged 3 commits into from
Jan 20, 2023

Conversation

sct
Copy link
Contributor

@sct sct commented Jan 13, 2023

For whatever reason, 1password was convinced that it should be trying to suggest something in the date picker field. This was frustrating because the calendar button would overlap with the 1password button and cause 1password to pop open whenever clicking to open the calendar.

This PR adds two props to let us pass a custom id/name attribute to the date input field. Setting any custom name will stop 1password from trying to suggest inputs.

CONTRIBUTING.md Outdated
@@ -1,18 +1,22 @@
# Contributing

Thanks for your interest in contributing to `react-tailwindcss-datepicker`! Please take a moment to review this document **before submitting a pull request**.
Thanks for your interest in contributing to `react-tailwindcss-datepicker`! Please take a moment to
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting complaints from prettier until I reran the formatting. This was likely committed without running prettier?

package.json Outdated
@@ -65,5 +65,8 @@
"tailwindcss": "^3.2.4",
"tslib": "^2.4.0",
"typescript": "^4.8.4"
},
"publishConfig": {
"registry": "https://registry.npmjs.com"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this for those of us who have different default registries. I hope you don't mind. Let me know if you would like to remove it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to leave this as it is. You can just add your default registry when you publish from your fork

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Will remove!

Comment on lines +184 to +185
autoComplete="off"
role="presentation"
Copy link
Contributor Author

@sct sct Jan 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are optional but should ensure other password managers leave these fields alone.

onChange={handleInputChange}
/>

<button
type="button"
ref={buttonRef}
disabled={disabled}
className="absolute right-0 h-full px-3 text-gray-400 focus:outline-none disabled:opacity-40 disabled:cursor-not-allowed"
className="absolute top-0 right-0 h-full px-3 text-gray-400 focus:outline-none disabled:opacity-40 disabled:cursor-not-allowed"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another minor fix I hope you don't mind me including. At least for me, the button was misaligned when rendering in my modal. Setting top-0 fixed the positioning in all my use-cases.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be much better if we add toggleClassName prop to pass in Datepicker component, so you can override the toggle button's class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Do we want to just have it append classes or overwrite them completely?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try having it append at the end of toggle button's className

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added toggleClassName to the button!

@@ -68,7 +70,9 @@ const Datepicker: React.FC<Props> = ({
readOnly = false,
minDate = null,
maxDate = null,
disabledDates = null
disabledDates = null,
inputId,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should consider having the id and name be optional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are optional in the type. They just don't accept null. id and name do not accept null as a value on an input field so this better represents the actual type where the values are used.

Copy link
Collaborator

@JefteCaro JefteCaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sct

Thank you for this PR.

See comments for PR changes.

@JefteCaro JefteCaro requested a review from onesine January 13, 2023 15:25
@sct sct requested review from JefteCaro and removed request for onesine January 19, 2023 12:50
@sct
Copy link
Contributor Author

sct commented Jan 19, 2023

Not sure why it removed the review request from @onesine but anything else you need me to do to get this merged?

@JefteCaro JefteCaro requested a review from onesine January 19, 2023 13:38
@@ -230,15 +232,15 @@ export default function Playground() {
/>
</div>
<div className="mb-2">
<label className="block" htmlFor="startWeekOnClassName">
Start Week On
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved "Start Week On" under the newly added "Toggle Class" input so the formatting of the inputs here looks a little better.

@JefteCaro JefteCaro merged commit b0df81d into onesine:master Jan 20, 2023
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

Successfully merging this pull request may close these issues.

2 participants