pnp / sp-dev-fx-property-controls

Reusable SPFx property pane controls - Open source initiative
https://pnp.github.io/sp-dev-fx-property-controls/
MIT License
233 stars 151 forks source link

Pnp file picker bug fix #588

Closed ClemSK closed 7 months ago

ClemSK commented 8 months ago
Q A
Bug fix? [x]
New feature? [ ]
New sample? [ ]
Related issues? fixes #X, partially #Y, mentioned in #Z

What's in this Pull Request?

Fix for issue #562 PR to go with my comment for the issue here: https://github.com/pnp/sp-dev-fx-property-controls/issues/562#issuecomment-1778810710

The problem is that the span tag in FolderTitle.tsx component can't render the Date object which is being passed with 'item.modified'. The FolderTile.tsx is a child component in TilesList.tsx which is why the Tiles layout closes the property pane when that layout is selected.

image

My error message was that React cannot render an object or something to that effect. Unfortunately, I don't have a screenshot of the error to show here.

To fix this behaviour, .toLocaleDateString() is called to display the date that was intended in the 'item.modified' Date object and get the site locale by prop-drilling to pass the SharePoint context value .currentCultureName. In case context is undefined or null, I'm setting a fallback to 'en-US'.

image

What the folder with a date looks like with an 'en-UK' locale set on the workbench: image

joelfmrodrigues commented 7 months ago

Many thanks @ClemSK , this is now merged