From 634c901262570c62af2b20964ed84bc01febc8ed Mon Sep 17 00:00:00 2001 From: anhcuky <42137630+anhcuky@users.noreply.github.com> Date: Thu, 19 Dec 2024 05:28:26 +0700 Subject: [PATCH] Enforce required validation on signup answers (#2865) --- .../components/common/markdown-textarea.tsx | 21 ++++++++++++------- src/shared/components/home/signup.tsx | 1 + 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/shared/components/common/markdown-textarea.tsx b/src/shared/components/common/markdown-textarea.tsx index bd2e3f46..3114c6dc 100644 --- a/src/shared/components/common/markdown-textarea.tsx +++ b/src/shared/components/common/markdown-textarea.tsx @@ -4,6 +4,7 @@ import autosize from "autosize"; import classNames from "classnames"; import { NoOptionI18nKeys } from "i18next"; import { Component, linkEvent } from "inferno"; +import { createElement } from "inferno-create-element"; import { Prompt } from "inferno-router"; import { Language } from "lemmy-js-client"; import { @@ -52,6 +53,7 @@ interface MarkdownTextAreaProps { onSubmit?(content: string, languageId?: number): Promise; allLanguages: Language[]; // TODO should probably be nullable siteLanguages: number[]; // TODO same + renderAsDiv?: boolean; } interface ImageUploadStatus { @@ -114,13 +116,16 @@ export class MarkdownTextArea extends Component< render() { const languageId = this.state.languageId; - - return ( -
+ return createElement( + this.props.renderAsDiv ? "div" : "form", + { + className: "markdown-textarea", + id: this.formId, + onSubmit: this.props.renderAsDiv + ? undefined + : linkEvent(this, this.handleSubmit), + }, + <> - + , ); } diff --git a/src/shared/components/home/signup.tsx b/src/shared/components/home/signup.tsx index 2af157e6..36371d05 100644 --- a/src/shared/components/home/signup.tsx +++ b/src/shared/components/home/signup.tsx @@ -303,6 +303,7 @@ export class Signup extends Component { hideNavigationWarnings allLanguages={[]} siteLanguages={[]} + renderAsDiv={true} />