diff --git a/.ash_history b/.ash_history index 7dba355e5..b2fa28548 100644 --- a/.ash_history +++ b/.ash_history @@ -21,3 +21,5 @@ npm install @pnp/spfx-property-controls --save --save-exact npm run serve gulp clean; gulp build; gulp bundle --ship; gulp package-solution --ship; npm run serve +exit +npm run serve diff --git a/src/components/autocomplete/Autocomplete.tsx b/src/components/autocomplete/Autocomplete.tsx index e1875e13e..1f49d8331 100644 --- a/src/components/autocomplete/Autocomplete.tsx +++ b/src/components/autocomplete/Autocomplete.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -// import styles from './Autocomplete.module.scss'; -import { TextField, ITextFieldProps, Callout, DirectionalHint, ITextField } from 'office-ui-fabric-react'; +import styles from './Autocomplete.module.scss'; +import { TextField, ITextFieldProps, Callout, ICalloutProps, DirectionalHint, ITextField, TextFieldBase } from 'office-ui-fabric-react'; import { isNullOrEmpty, cssClasses, getDeepOrDefault, isFunction } from '@spfxappdev/utility'; @@ -9,6 +9,9 @@ export interface IAutocompleteProps extends Omit; } interface IAutocompleteState { @@ -25,7 +28,10 @@ export class Autocomplete extends React.Component { + return (<> { this.textFieldReference = input; this.textFieldDomElement = getDeepOrDefault(input, "_textElement.current", null); + if(isFunction(this.props.textFieldRef)) { + this.props.textFieldRef(input, this, this.textFieldDomElement); + } }} onFocus={(ev: any) => { @@ -64,12 +77,7 @@ export class Autocomplete extends React.Component { - - this.onValueChanged(newValue); - - if(isFunction(this.props.onChange)) { - this.props.onChange(ev, newValue); - } + this.onValueChanged(ev, newValue); }} defaultValue={this.state.currentValue} /> @@ -78,17 +86,45 @@ export class Autocomplete extends React.Component); } + public updateValue(newValue: string): void { + this.onUpdateValueText = newValue; + + this.setState({ + currentValue: newValue + }, () => { + (this.textFieldReference as TextFieldBase).setState({ + uncontrolledValue: this.onUpdateValueText + }); + + if(isFunction(this.props.onUpdated)) { + this.props.onUpdated(newValue); + } + }); + } + private renderSuggesstionsFlyout(): JSX.Element { + let minWidth: number = getDeepOrDefault(this.props, "calloutProps.calloutMinWidth", -1); + + if(minWidth <= 0) { + minWidth = getDeepOrDefault(this, "textFieldDomElement.clientWidth", -1); + } + + if(minWidth > 0) { + this.props.calloutProps.calloutMinWidth = minWidth; + } + return (