From b62e1a281edae213227c0e2901ae0b350874f7e5 Mon Sep 17 00:00:00 2001 From: Sergej Schwabauer Date: Fri, 4 Mar 2022 11:50:41 +0100 Subject: [PATCH] Iconpicker and Bugfixes --- .ash_history | 2 + src/components/autocomplete/Autocomplete.tsx | 74 ++++++++++++---- .../iconPicker/IconPicker.module.scss | 32 +++++++ src/components/iconPicker/IconPicker.tsx | 68 +++++++++++---- src/webparts/map/MapWebPart.manifest.json | 3 +- src/webparts/map/MapWebPart.ts | 85 ++++++++++++++----- .../map/components/AddOrEditPanel.tsx | 18 +++- src/webparts/map/components/IMapProps.ts | 1 + .../ManageMarkerCategoriesDialog.tsx | 6 +- src/webparts/map/components/Map.module.scss | 7 +- src/webparts/map/components/Map.tsx | 18 ++-- src/webparts/map/loc/en-us.js | 13 +-- src/webparts/map/loc/mystrings.d.ts | 3 + 13 files changed, 261 insertions(+), 69 deletions(-) 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 (