Skip to content

Commit

Permalink
Merge branch 'dev' into fix-for-1788-and-add-styles-property
Browse files Browse the repository at this point in the history
  • Loading branch information
wuxiaojun514 authored Dec 12, 2024
2 parents 815f441 + fe8f98f commit 187379e
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 14 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
{
"versions": [
{
"version": "3.21.0",
"changes": {
"new": [],
"enhancements": [],
"fixes": [
"`ListItemComments`: Can't select text from comment [#1874](https://github.com/pnp/sp-dev-fx-controls-react/issues/1874)",
"`Localization`: Bad translations in DateTimePicker control [#1909](https://github.com/pnp/sp-dev-fx-controls-react/issues/1909)",
"`WebPartTitle`: Control Fails to Update After Initial Save [#1877](https://github.com/pnp/sp-dev-fx-controls-react/issues/1877)",
"`DynamicForm`: Creating a document set sometimes throws a 409 save [#1919](https://github.com/pnp/sp-dev-fx-controls-react/issues/1919)"
]
},
"contributions": [
"[Alessandro Chiavarino](https://github.com/Alesso-Chiavarino)",
"[Antanina Druzhkina](https://github.com/Ateina)",
"[EnablingLogic](https://github.com/EnablingLogic)",
"[Martin Lingstuyl](https://github.com/martinlingstuyl)"
]
},
{
"version": "3.20.0",
"changes": {
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Releases

## 3.21.0

### Fixes

- `ListItemComments`: Can't select text from comment [#1874](https://github.com/pnp/sp-dev-fx-controls-react/issues/1874)
- `Localization`: Bad translations in DateTimePicker control [#1909](https://github.com/pnp/sp-dev-fx-controls-react/issues/1909)
- `WebPartTitle`: Control Fails to Update After Initial Save [#1877](https://github.com/pnp/sp-dev-fx-controls-react/issues/1877)
- `DynamicForm`: Creating a document set sometimes throws a 409 save [#1919](https://github.com/pnp/sp-dev-fx-controls-react/issues/1919)

### Contributors

Special thanks to our contributors (in alphabetical order): [Alessandro Chiavarino](https://github.com/Alesso-Chiavarino), [Antanina Druzhkina](https://github.com/Ateina), [EnablingLogic](https://github.com/EnablingLogic), [Martin Lingstuyl](https://github.com/martinlingstuyl).

## 3.20.0

### Enhancements
Expand Down
13 changes: 13 additions & 0 deletions docs/documentation/docs/about/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Releases

## 3.21.0

### Fixes

- `ListItemComments`: Can't select text from comment [#1874](https://github.com/pnp/sp-dev-fx-controls-react/issues/1874)
- `Localization`: Bad translations in DateTimePicker control [#1909](https://github.com/pnp/sp-dev-fx-controls-react/issues/1909)
- `WebPartTitle`: Control Fails to Update After Initial Save [#1877](https://github.com/pnp/sp-dev-fx-controls-react/issues/1877)
- `DynamicForm`: Creating a document set sometimes throws a 409 save [#1919](https://github.com/pnp/sp-dev-fx-controls-react/issues/1919)

### Contributors

Special thanks to our contributors (in alphabetical order): [Alessandro Chiavarino](https://github.com/Alesso-Chiavarino), [Antanina Druzhkina](https://github.com/Ateina), [EnablingLogic](https://github.com/EnablingLogic), [Martin Lingstuyl](https://github.com/martinlingstuyl).

## 3.20.0

### Enhancements
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@pnp/spfx-controls-react",
"description": "Reusable React controls for SharePoint Framework solutions",
"version": "3.20.0",
"version": "3.21.0",
"node": ">=16.13.0 <17.0.0 || >=18.17.1 <19.0.0",
"scripts": {
"build": "gulp build",
Expand Down
2 changes: 1 addition & 1 deletion src/common/telemetry/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version: string = "3.20.0";
export const version: string = "3.21.0";
34 changes: 31 additions & 3 deletions src/controls/dynamicForm/DynamicForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import "@pnp/sp/content-types";
import "@pnp/sp/folders";
import "@pnp/sp/items";
import { IFolder } from "@pnp/sp/folders";
import { IInstalledLanguageInfo } from "@pnp/sp/presets/all";
import { IInstalledLanguageInfo, IItemUpdateResult, IList } from "@pnp/sp/presets/all";
import { cloneDeep, isEqual } from "lodash";
import { ICustomFormatting, ICustomFormattingBodySection, ICustomFormattingNode } from "../../common/utilities/ICustomFormatting";
import SPservice from "../../services/SPService";
Expand All @@ -56,6 +56,10 @@ const getstyles = classNamesFunction<IDynamicFormStyleProps, IDynamicFormStyles>
const getFieldstyles = classNamesFunction<IDynamicFieldStyleProps, IDynamicFieldStyles>();
const theme = getFluentUIThemeOrDefault();

const timeout = (ms: number): Promise<void> => {
return new Promise((resolve) => setTimeout(resolve, ms));
};

/**
* DynamicForm Class Control
*/
Expand Down Expand Up @@ -626,7 +630,7 @@ export class DynamicFormBase extends React.Component<
// Set the content type ID for the target item
objects[contentTypeIdField] = contentTypeId;
// Update the just created folder or Document Set
const iur = await library.items.getById(folderId).update(objects);
const iur = await this.updateListItemRetry(library, folderId, objects);
if (onSubmitted) {
onSubmitted(
iur.data,
Expand Down Expand Up @@ -704,7 +708,7 @@ export class DynamicFormBase extends React.Component<
// Set the content type ID for the target item
objects[contentTypeIdField] = contentTypeId;
// Update the just created file
const iur = await library.items.getById(fileId).update(objects);
const iur = await this.updateListItemRetry(library, fileId, objects);
if (onSubmitted) {
onSubmitted(
iur.data,
Expand Down Expand Up @@ -1537,6 +1541,30 @@ export class DynamicFormBase extends React.Component<
const folder = sp.web.getFolderByServerRelativePath(`${serverRelativeLibraryPath}/${normalizedFolderPath}`);
return folder;
};

/**
* Updates a list item and retries the operation if a 409 (Save Conflict) was thrown.
* @param list The list/library on which to execute the operation
* @param itemId The item ID
* @param objects The values to update the item with
* @param retry The retry index
* @returns An update result
*/
private updateListItemRetry = async (list: IList, itemId: number, objects: {}, retry: number = 0): Promise<IItemUpdateResult> => {
try {
return await list.items.getById(itemId).update(objects);
}
catch (error)
{
if (error.status === 409 && retry < 3) {
await timeout(100);
return await this.updateListItemRetry(list, itemId, objects, retry + 1);
}

throw error;
}
}

}

export const DynamicForm = styled<IDynamicFormProps, IDynamicFormStyleProps, IDynamicFormStyles>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const useListItemCommentsStyles = (): returnObjectStyles => {
marginBottom: 7,
width: 322,
backgroundColor: theme.neutralLighterAlt,
userSelect: "text",
":hover": {
borderColor: theme.themePrimary,
borderWidth: 1,
Expand All @@ -64,6 +65,7 @@ export const useListItemCommentsStyles = (): returnObjectStyles => {
marginBottom: 7,
width: 322,
backgroundColor: theme.themeLighter,
userSelect: "text",
border: "solid 3px "+theme.themePrimary,
":hover": {
borderColor: theme.themePrimary,
Expand Down
2 changes: 1 addition & 1 deletion src/controls/webPartTitle/WebPartTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class WebPartTitle extends React.Component<IWebPartTitleProps, {}> {
<div className={styles.webPartTitle} style={{ color: color }}>
{
this.props.displayMode === DisplayMode.Edit && (
<textarea placeholder={this.props.placeholder ? this.props.placeholder : strings.WebPartTitlePlaceholder} aria-label={strings.WebPartTitleLabel} onChange={this._onChange} value={this.props.title} />
<textarea placeholder={this.props.placeholder ? this.props.placeholder : strings.WebPartTitlePlaceholder} aria-label={strings.WebPartTitleLabel} onChange={this._onChange} defaultValue={this.props.title} />
)
}

Expand Down
12 changes: 6 additions & 6 deletions src/loc/ca-es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,19 @@ define([], () => {
"DatePickerMonthLongDecember": "Desembre",
"DatePickerMonthShortDecember": "Desembre",
"DatePickerDayLongSunday": "Diumenge",
"DatePickerDayShortSunday": "Sol",
"DatePickerDayShortSunday": "Diu",
"DatePickerDayLongMonday": "Dilluns",
"DatePickerDayShortMonday": "Meu",
"DatePickerDayShortMonday": "Dil",
"DatePickerDayLongTuesday": "Dimarts",
"DatePickerDayShortTuesday": "Dm",
"DatePickerDayShortTuesday": "Dim",
"DatePickerDayLongWednesday": "Dimecres",
"DatePickerDayShortWednesday": "Dc",
"DatePickerDayShortWednesday": "Dmc",
"DatePickerDayLongThursday": "Dijous",
"DatePickerDayShortThursday": "Dij",
"DatePickerDayLongFriday": "Divendres",
"DatePickerDayShortFriday": "Dv",
"DatePickerDayShortFriday": "Div",
"DatePickerDayLongSaturday": "Dissabte",
"DatePickerDayShortSaturday": "Ds",
"DatePickerDayShortSaturday": "Dis",
"DatePickerGoToToday": "Avui",
"DatePickerIsRequiredErrorMessage": "",
"DatePickerInvalidInputErrorMessage": "",
Expand Down

0 comments on commit 187379e

Please sign in to comment.