Open platform to collect and prioritize feedback
fix: enable submission of post when pressing enter (#808)
Guilherme Oenning42d822133da2
diff --git a/public/components/common/Button.tsx b/public/components/common/Button.tsxindex aa772ce52..19e0787ab 100644--- a/public/components/common/Button.tsx+++ b/public/components/common/Button.tsx@@ -6,6 +6,7 @@ interface ButtonProps {disabled?: boolean;href?: string;rel?: "nofollow";+ type?: "button" | "submit";color?: "positive" | "danger" | "default" | "cancel";fluid?: boolean;size?: "mini" | "tiny" | "small" | "normal" | "large";@@ -34,7 +35,8 @@ export class Button extends React.Component<ButtonProps, ButtonState> {public static defaultProps: Partial<ButtonProps> = {size: "small",fluid: false,- color: "default"+ color: "default",+ type: "button"};public constructor(props: ButtonProps) {@@ -87,13 +89,13 @@ export class Button extends React.Component<ButtonProps, ButtonState> {);} else if (this.props.onClick) {return (- <button type="button" className={className} onClick={this.click}>+ <button type={this.props.type} className={className} onClick={this.click}>{this.props.children}</button>);} else {return (- <button type="button" className={className}>+ <button type={this.props.type} className={className}>{this.props.children}</button>);diff --git a/public/components/common/SignInControl.tsx b/public/components/common/SignInControl.tsxindex c1dc12e51..88019a510 100644--- a/public/components/common/SignInControl.tsx+++ b/public/components/common/SignInControl.tsx@@ -71,10 +71,9 @@ export const SignInControl: React.FunctionComponent<SignInControlProps> = propsvalue={email}autoFocus={!device.isTouch()}onChange={setEmail}- onSubmit={signIn}placeholder="[email protected]"suffix={- <Button color="positive" disabled={email === ""} onClick={signIn}>+ <Button type="submit" color="positive" disabled={email === ""} onClick={signIn}>Sign in</Button>}diff --git a/public/components/common/form/Input.tsx b/public/components/common/form/Input.tsxindex 817f3154f..39744a48e 100644--- a/public/components/common/form/Input.tsx+++ b/public/components/common/form/Input.tsx@@ -19,7 +19,6 @@ interface InputProps {suffix?: string | JSX.Element;placeholder?: string;onIconClick?: () => void;- onSubmit?: () => void;onFocus?: () => void;inputRef?: (node: HTMLInputElement) => void;onChange?: (value: string) => void;@@ -32,13 +31,6 @@ export const Input: React.FunctionComponent<InputProps> = props => {}};- const onKeyDown = (event: React.KeyboardEvent<HTMLInputElement>): void => {- if (event.keyCode === 13 && props.onSubmit) {- props.onSubmit();- event.preventDefault();- }- };-const suffix =typeof props.suffix === "string" ? <span className="c-form-input-suffix">{props.suffix}</span> : props.suffix;@@ -80,7 +72,6 @@ export const Input: React.FunctionComponent<InputProps> = props => {disabled={props.disabled}value={props.value}placeholder={props.placeholder}- onKeyDown={props.onSubmit ? onKeyDown : undefined}onChange={onChange}/>{icon}diff --git a/public/pages/CompleteSignInProfile/CompleteSignInProfile.page.tsx b/public/pages/CompleteSignInProfile/CompleteSignInProfile.page.tsxindex b969a5c0c..48bc07323 100644--- a/public/pages/CompleteSignInProfile/CompleteSignInProfile.page.tsx+++ b/public/pages/CompleteSignInProfile/CompleteSignInProfile.page.tsx@@ -46,10 +46,9 @@ export default class CompleteSignInProfilePage extends React.Component<HomePagePfield="name"onChange={this.setName}maxLength={100}- onSubmit={this.submit}placeholder="Name"suffix={- <Button onClick={this.submit} color="positive" disabled={this.state.name === ""}>+ <Button type="submit" onClick={this.submit} color="positive" disabled={this.state.name === ""}>Submit</Button>}diff --git a/public/pages/Home/components/PostInput.tsx b/public/pages/Home/components/PostInput.tsxindex 07b795dca..d6cfdf0b5 100644--- a/public/pages/Home/components/PostInput.tsx+++ b/public/pages/Home/components/PostInput.tsx@@ -90,7 +90,7 @@ export class PostInput extends React.Component<PostInputProps, PostInputState> {placeholder="Describe your suggestion (optional)"/><MultiImageUploader field="attachments" maxUploads={3} previewMaxWidth={100} onChange={this.setAttachments} />- <Button color="positive" onClick={this.submit}>+ <Button type="submit" color="positive" onClick={this.submit}>Submit</Button></>