Skip to content

Commit 1948f6f

Browse files
committed
Merge branch 'AJIXuMuK-116' into dev
2 parents 7cd4e76 + 3e57524 commit 1948f6f

File tree

3 files changed

+59
-11
lines changed

3 files changed

+59
-11
lines changed

CHANGELOG.JSON

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@
55
"changes": {
66
"new": [],
77
"enhancements": [
8-
"`PeoplePicker`: ability to specify the source site to load users from [#110](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/110)",
98
"`PeoplePicker`: Specify to hide or show the users/groups which are hidden in the UI [#122](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/122)",
10-
"`PeoplePicker`: Specify principle type to retrieve (users, groups, ...) [#122](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/122)",
119
"`WebPartTitle`: changing font-sizes on different resolutions [#114](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/114)",
1210
"`WebPartTitle`: Added accessibility tags for web part title [#121](https://github.com/SharePoint/sp-dev-fx-controls-react/pull/121)",
1311
"`ListView`: Resizable columns - introduced a `isResizable` property [#119](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/119)",
12+
"`FieldNameRenderer` double click support added [#116](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/116)",
1413
"`TaxonomyPicker`: table markup changed to DIV [#113](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/113)",
15-
"`TaxonomyPicker`: Disable the terms which are set as deprecated or unavailable for tagging [#109](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/109)"
14+
"`PeoplePicker`: ability to specify the source site to load users from [#110](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/110)",
15+
"`TaxonomyPicker`: Disable the terms which are set as deprecated or unavailable for tagging [#109](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/109)",
16+
"`PeoplePicker`: Specify principle type to retrieve (users, groups, ...) [#94](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/94)"
1617
],
1718
"fixes": [
1819
"`IFrameDialog`: dialog width is not correct in IE11 [#118](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/118)",
1920
"`PeoplePicker`: fix freezes when typing in search values [#117](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/117)"
2021
]
2122
},
22-
"contributions": ["[Thomas Lamb](https://github.com/ThomasLamb)", "[Joel Rodrigues](https://github.com/joelfmrodrigues)", "[Mikael Svenson](https://github.com/wobba)"]
23+
"contributions": ["[Thomas Lamb](https://github.com/ThomasLamb)", "[Joel Rodrigues](https://github.com/joelfmrodrigues)", "[Mikael Svenson](https://github.com/wobba)", "[Alex Terentiev](https://github.com/AJIXuMuK)"]
2324
},
2425
{
2526
"version": "1.7.0",

docs/documentation/docs/controls/fields/FieldNameRenderer.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ The FieldNameRenderer component can be configured with the following properties:
3737
| isLink | boolean | yes | True if the name should be rendered as a link. |
3838
| isNew | boolean | no | True if the document is new. |
3939
| filePath | string | no | Path to the document. |
40-
| hasPreview | boolean | no | True if the document has preview (true by default) |
41-
| onClick | (args: INameClickEventArgs) => {} | no | Custom handler for link click. If not set link click will lead to rendering document preview. |
42-
40+
| hasPreview | boolean | no | True if the document has preview and link href should be constructed to display the preview (instead of direct document's link). The flag works only if `onClick` property is NOT defined. |
41+
| onClick | (args: INameClickEventArgs) => {} | no | Custom handler for link click. If not set link click will lead to rendering document preview. Works if `isLink` is set to `true` |
42+
| onDoubleClick | (args: INameClickEventArgs) => {} | no | Custom handler for link double click. If not set link If not set link will use OOTB behavior. Works if `isLink` is set to `true` |
4343

4444
![](https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/fields/FieldNameRenderer)
4545

src/controls/fields/fieldNameRenderer/FieldNameRenderer.tsx

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { override } from '@microsoft/decorators';
22
import * as React from 'react';
3+
import * as ReactDOM from 'react-dom';
4+
35
import { css } from 'office-ui-fabric-react/lib/Utilities';
46
import { Icon } from 'office-ui-fabric-react/lib/Icon';
57
import { Link } from 'office-ui-fabric-react/lib/Link';
@@ -28,13 +30,20 @@ export interface IFieldNameRendererProps extends IFieldRendererProps {
2830
*/
2931
isNew?: boolean;
3032
/**
31-
* true if the document type has preview (true by default)
33+
* true if the document type has preview (true by default).
34+
* The flag impacts on the link's href:
35+
* if the flag is tru then the href is constructed like #id=${filePath}&parent=${filePath.substring(0, filePath.lastIndexOf('/'))},
36+
* otherwise the href will contain filePath only.
3237
*/
3338
hasPreview?: boolean;
3439
/**
3540
* custom handler for link click. If not set link click will lead to rendering document preview
3641
*/
3742
onClick?: (args: IFieldNameClickEventArgs) => {};
43+
/**
44+
* custom handler for link double click. If not set link will use OOTB behavior.
45+
*/
46+
onDoubleClick?: (args: IFieldNameClickEventArgs) => {};
3847
}
3948

4049
/**
@@ -57,12 +66,37 @@ export interface IFieldNameClickEventArgs {
5766
* - Title
5867
*/
5968
export class FieldNameRenderer extends React.Component<IFieldNameRendererProps, IFieldNameRendererState> {
69+
private _button: HTMLButtonElement;
70+
6071
public constructor(props: IFieldNameRendererProps, state: IFieldNameRendererState) {
6172
super(props, state);
6273

6374
telemetry.track('FieldNameRenderer', {});
6475

6576
this.state = {};
77+
78+
this._onDoubleClick = this._onDoubleClick.bind(this);
79+
}
80+
81+
@override
82+
public componentDidMount() {
83+
//
84+
// small hack for double click.
85+
// unfortunately, we can't use React onDoubleClick because React doesn't guaranty the sequence of handlers.
86+
// And stopPropagation could not make effect.
87+
//
88+
if (this.props.onDoubleClick && this.props.isLink) {
89+
const domNode = ReactDOM.findDOMNode(this);
90+
this._button = domNode.querySelector('button');
91+
this._button.addEventListener('dblclick', this._onDoubleClick, false);
92+
}
93+
}
94+
95+
@override
96+
public componentWillUnmount() {
97+
if (this._button) {
98+
this._button.removeEventListener('dblclick', this._onDoubleClick);
99+
}
66100
}
67101

68102
@override
@@ -76,7 +110,10 @@ export class FieldNameRenderer extends React.Component<IFieldNameRendererProps,
76110

77111
if (isLink) {
78112
if (this.props.onClick) {
79-
value = <Link onClick={this._onClick.bind(this)} style={this.props.cssProps} className={styles.value}>{this.props.text}</Link>;
113+
value = <Link
114+
onClick={this._onClick.bind(this)}
115+
style={this.props.cssProps}
116+
className={styles.value}>{this.props.text}</Link>;
80117
}
81118
else {
82119
let url: string;
@@ -103,13 +140,23 @@ export class FieldNameRenderer extends React.Component<IFieldNameRendererProps,
103140
</span>;
104141
}
105142

106-
private _onClick(e): void {
143+
private _onClick(e): boolean {
107144
if (this.props.onClick) {
108145
e.stopPropagation();
109146
e.preventDefault();
110147
const args: IFieldNameClickEventArgs = this.props as IFieldNameClickEventArgs;
111148
this.props.onClick(args);
112-
return;
149+
return false;
150+
}
151+
}
152+
153+
private _onDoubleClick(e): boolean {
154+
if (this.props.onDoubleClick) {
155+
e.stopPropagation();
156+
e.preventDefault();
157+
const args: IFieldNameClickEventArgs = this.props as IFieldNameClickEventArgs;
158+
this.props.onDoubleClick(args);
159+
return false;
113160
}
114161
}
115162
}

0 commit comments

Comments
 (0)