Skip to content
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

[0.8] Allow the format property to be omitted #3812

Merged
merged 1 commit into from
Feb 9, 2023

Conversation

Karibash
Copy link
Contributor

@Karibash Karibash commented Feb 3, 2023

The current behavior

The format property allows undefined, but cannot be omitted because it is not optional.

format: ElementFormatType | null | undefined;

class LinkCardNode extends DecoratorNode<React.ReactElement> {
  public decorate(editor: LexicalEditor, config: EditorConfig): React.ReactElement {
    return (
      <BlockWithAlignableContents
        className={className}
        format={undefined} // undefined must be specified.
        nodeKey={this.getKey()}
      >
        text
      </BlockWithAlignableContents>
    );
  }
}

The expected behavior

Change the format property to optional so that it can be omitted.

type Props = Readonly<{
  format?: ElementFormatType | null;
}>;
class LinkCardNode extends DecoratorNode<React.ReactElement> {
  public decorate(editor: LexicalEditor, config: EditorConfig): React.ReactElement {
    return (
      <BlockWithAlignableContents
        className={className}
        nodeKey={this.getKey()}
      >
        text
      </BlockWithAlignableContents>
    );
  }
}

@vercel
Copy link

vercel bot commented Feb 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
lexical ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 3, 2023 at 3:49AM (UTC)
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 3, 2023 at 3:49AM (UTC)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 3, 2023
@thegreatercurve
Copy link
Contributor

Thanks. This looks fine to me! We'll include it in a 0.8 release as it constitutes a break change.

@thegreatercurve thegreatercurve changed the title Allow the format property to be omitted [0.8] Allow the format property to be omitted Feb 3, 2023
@trueadm trueadm merged commit 060cee7 into facebook:main Feb 9, 2023
@thegreatercurve thegreatercurve mentioned this pull request Feb 9, 2023
@Karibash Karibash deleted the feature/format-property-omitted branch February 9, 2023 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants