Enforce required validation on signup answers (#2865)

This commit is contained in:
anhcuky 2024-12-19 05:28:26 +07:00 committed by GitHub
parent 6e04efab2d
commit 634c901262
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 8 deletions

View file

@ -4,6 +4,7 @@ import autosize from "autosize";
import classNames from "classnames"; import classNames from "classnames";
import { NoOptionI18nKeys } from "i18next"; import { NoOptionI18nKeys } from "i18next";
import { Component, linkEvent } from "inferno"; import { Component, linkEvent } from "inferno";
import { createElement } from "inferno-create-element";
import { Prompt } from "inferno-router"; import { Prompt } from "inferno-router";
import { Language } from "lemmy-js-client"; import { Language } from "lemmy-js-client";
import { import {
@ -52,6 +53,7 @@ interface MarkdownTextAreaProps {
onSubmit?(content: string, languageId?: number): Promise<boolean>; onSubmit?(content: string, languageId?: number): Promise<boolean>;
allLanguages: Language[]; // TODO should probably be nullable allLanguages: Language[]; // TODO should probably be nullable
siteLanguages: number[]; // TODO same siteLanguages: number[]; // TODO same
renderAsDiv?: boolean;
} }
interface ImageUploadStatus { interface ImageUploadStatus {
@ -114,13 +116,16 @@ export class MarkdownTextArea extends Component<
render() { render() {
const languageId = this.state.languageId; const languageId = this.state.languageId;
return createElement(
return ( this.props.renderAsDiv ? "div" : "form",
<form {
className="markdown-textarea" className: "markdown-textarea",
id={this.formId} id: this.formId,
onSubmit={linkEvent(this, this.handleSubmit)} onSubmit: this.props.renderAsDiv
> ? undefined
: linkEvent(this, this.handleSubmit),
},
<>
<Prompt <Prompt
message={I18NextService.i18n.t("block_leaving")} message={I18NextService.i18n.t("block_leaving")}
when={ when={
@ -306,7 +311,7 @@ export class MarkdownTextArea extends Component<
)} )}
</div> </div>
</div> </div>
</form> </>,
); );
} }

View file

@ -303,6 +303,7 @@ export class Signup extends Component<SignupRouteProps, State> {
hideNavigationWarnings hideNavigationWarnings
allLanguages={[]} allLanguages={[]}
siteLanguages={[]} siteLanguages={[]}
renderAsDiv={true}
/> />
</div> </div>
</div> </div>