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

feat: add localized formatting #2160

Merged
merged 18 commits into from
May 24, 2024
Merged

feat: add localized formatting #2160

merged 18 commits into from
May 24, 2024

Conversation

LuLaValva
Copy link
Member

@LuLaValva LuLaValva commented Apr 22, 2024

Addresses: #2174

Description

Use date-fns to localize date format in date textbox instead of using ISO.

Note

date-fns maintains their own list of locales that likely doesn't exactly match the browser. This is likely something we will need to maintain ourselves, or provide/find a mapping

Screenshots

image image

@LuLaValva LuLaValva self-assigned this Apr 22, 2024
Copy link

changeset-bot bot commented Apr 22, 2024

🦋 Changeset detected

Latest commit: 629b7d8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@ebay/ebayui-core Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@LuLaValva LuLaValva marked this pull request as ready for review April 22, 2024 20:50
Copy link
Contributor

@agliga agliga left a comment

Choose a reason for hiding this comment

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

Please update from master. Lets try to get this in a patch but lets fix conflicts first.

@LuLaValva
Copy link
Member Author

I'll update from master, but I think this should be part of at least a minor version since placeholder text will need to be updated in applications that are using the component.

@agliga
Copy link
Contributor

agliga commented Apr 30, 2024

I'll update from master, but I think this should be part of at least a minor version since placeholder text will need to be updated in applications that are using the component.

Can you show what teams need to do and what will break for teams?
Maybe we can add a temporary opt in for this localization so that teams can opt into it and then update the placeholder so its not breaking.

@LuLaValva
Copy link
Member Author

This is actually nontrivial for teams, since the placeholder needs to switch from being unconditionally YYYY-MM-DD to a localized format like MM/DD/YYYY for each locale. Alternatively, the placeholder can be removed or replaced with something like Date

@agliga
Copy link
Contributor

agliga commented May 1, 2024

This is actually nontrivial for teams, since the placeholder needs to switch from being unconditionally YYYY-MM-DD to a localized format like MM/DD/YYYY for each locale. Alternatively, the placeholder can be removed or replaced with something like Date

So for now: lets not make this automatic. If they want to get this new functionality, have them pass an argument like auto-localize=true.
Next major version we will remove that flag and have it turn on by default.

agliga
agliga previously approved these changes May 8, 2024
Copy link
Contributor

@agliga agliga left a comment

Choose a reason for hiding this comment

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

Approving for now if that placeholder issue is fixed.

@LuLaValva LuLaValva changed the base branch from master to 13.5.0 May 15, 2024 21:09
@agliga
Copy link
Contributor

agliga commented May 15, 2024

Need to update snapshots in tests. @LuLaValva

@agliga agliga linked an issue May 17, 2024 that may be closed by this pull request
@LuLaValva LuLaValva changed the title feat: add localized formatting using date-fns feat: add localized formatting May 23, 2024
@agliga
Copy link
Contributor

agliga commented May 24, 2024

LGTM overall codewise
I see a couple of bugs.

In localized we should use localizedFormat by default. We should also update the placeholder there. That said, could we have the placeholder be automatically generated from the formatter?
Also theres a bad bug if I type in a bad date using dashes for example, it removes all the content. We should not select a date in that case but never remove the value of the textfield.

@LuLaValva
Copy link
Member Author

Thanks for the review @agliga, while making an example for the error state I realized that we do not expose the necessary attributes for the textbox, so instead of continuing indirection I opted to add an @textbox attribute tag and deprecate input-placeholder-text and floating-label for use here instead. This is not breaking because current code will still work, but I think we should remove them in the next major in favor of @textbox attributes.

Copy link
Contributor

@agliga agliga left a comment

Choose a reason for hiding this comment

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

LGTM just make sure CI passes

@LuLaValva LuLaValva merged commit 5c71772 into 13.5.0 May 24, 2024
2 checks passed
@LuLaValva LuLaValva deleted the date-fns-localized-format branch May 24, 2024 22:29
This was referenced May 24, 2024
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.

date-textbox: allow localized date formats
3 participants