-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DynamicForm RichText Field losing focus on typing #1024
Comments
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible. |
Thank you @SmarterJB for reporting this one. I can repro it and will take a look. |
@AJIXuMuK - I'm fairly sure this is a similar issue to the one you fixed in #666 - if I modify https://github.com/pnp/sp-dev-fx-controls-react/blob/master/src/controls/richText/RichText.tsx#L630 and swap |
Hello @AJIXuMuK, I've tried to reproduce the issue with RichText component by simulating DynamicForm behaviour and I succeeded 😊 If you change from |
A solution would be to replace 'Note' case in case 'Note':
if (isRichText) {
const value = this.props.newValue ? this.props.newValue : defaultValue;
return <div className={styles.richText}>
<div className={styles.titleContainer}>
<Icon className={styles.fieldIcon} iconName={"AlignLeft"} />
{labelEl}
</div>
<RichText
placeholder={placeholder}
// Workaround for field losing focus
value={value}
className={styles.feildDisplay}
onChange={(newText) => {
this.onChange(newText);
return newText;
}}
isEditMode={disabled}
/>
{descriptionEl}
{errorTextEl}
</div>;
}
else {
return <div>
<div className={styles.titleContainer}>
<Icon className={styles.fieldIcon} iconName={"AlignLeft"} />
{labelEl}
</div>
<TextField
defaultValue={defaultValue}
placeholder={placeholder}
className={styles.feildDisplay}
multiline
onChange={(e, newText) => { this.onChange(newText); }}
disabled={disabled}
onBlur={this.onBlur}
errorMessage={errorText}
/>
{descriptionEl}
</div>;
} New value contains updated value, so rich text field will not set back to old value, which causes re-render to happen multiple times and lose focus. |
Category
[ ] Enhancement
[X] Bug
[ ] Question
Version
Please specify what version of the library you are using: [ 3.3.0 ]
Expected / Desired Behavior / Question
Using the DynamicForm component with a RichText field should not lose focus when typing in the rich text field.
Observed Behavior
If you try to type in a RichText field in the DynamicForm you lose focus after each character.
Steps to Reproduce
Use the DynamicForm in any list with a RichText field.
Thanks!
The text was updated successfully, but these errors were encountered: