pnp / pnp/sp-dev-fx-controls-react
DynamicForm renders DateTime fields as date-only when DateFormat is null
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 433
- Forks
- 418
- Avg merge
- 5d 6m
- Merged PRs (30d)
- 19
Description
Category
- Enhancement
- Bug
- Question
Version
3.25.0
Environment:
- SharePoint Online
- SPFx
1.22.2 - React
17.0.1 - Fluent UI 8
Expected / Desired Behavior / Question
DynamicForm should render a SharePoint Date and Time column using the DateTimePicker control when the SharePoint form metadata reports:
{
"FieldType": "DateTime",
"DisplayFormat": 1
}
The control should preserve the configured SharePoint field behavior, including the time portion.
Observed Behavior
DynamicForm renders the field using the date-only DatePicker.
The SharePoint RenderListDataAsStream response contains:
InternalName: Validfrom
FieldType: DateTime
DateFormat: null
DisplayFormat: 1
and:
InternalName: Validuntil
FieldType: DateTime
DateFormat: null
DisplayFormat: 1
The current implementation uses:
dateFormat = field.DateFormat || "DateOnly";
Because DateFormat is null, the field is incorrectly resolved as DateOnly, even though DisplayFormat: 1 indicates Date and Time.
Steps to Reproduce
- Create a SharePoint list with a Date and Time column.
- Configure the column to include both date and time.
- Render the list form using
DynamicForm. - Open the New Item form.
- Observe that the field displays only a date picker and does not provide time selection.
- Inspect the
RenderListDataAsStreamresponse using:
POST /_api/web/lists(guid<'list-id>')/RenderListDataAsStream
with:
{
"parameters": {
"RenderOptions": 64,
"ViewXml": "<View><ViewFields><FieldRef Name=\"ID\"/></ViewFields></View>",
"AddRequiredFields": true
}
}
The response reports FieldType: "DateTime" and DisplayFormat: 1, while DateFormat is null.
Additional Context
DisplayFormat appears to be the reliable property for determining whether a SharePoint DateTime field is date-only or date-and-time:
DisplayFormat: 0= Date onlyDisplayFormat: 1= Date and Time
A possible fix is to use DisplayFormat when resolving the field control, for example:
dateFormat = field.DisplayFormat === 1 ? "DateTime" : "DateOnly";
This issue affects DateTime fields whose DateFormat property is returned as null by SharePoint.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the DynamicForm field-control resolution where dateFormat = field.DateFormat || "DateOnly" is used. Compare the SharePoint metadata values FieldType, DateFormat, and DisplayFormat, then verify that DisplayFormat: 1 renders a DateTimePicker while DisplayFormat: 0 remains date-only. Done means DateTime fields with null DateFormat preserve time selection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100