mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 03:14:03 +03:00
Removed validation onBlur (#19358)
Fixes [PROD-209](https://linear.app/tryghost/issue/PROD-209/when-an-input-is-focused-and-a-modal-is-closed-error-messages-are)
This commit is contained in:
parent
a9c9202b5c
commit
f29d7975a8
@ -170,11 +170,6 @@ const Sidebar: React.FC<SidebarProps> = ({tierOptions,
|
||||
maxLength={40}
|
||||
placeholder='Black Friday'
|
||||
title='Offer name'
|
||||
onBlur={(e) => {
|
||||
if (!e.target.value && e.target.value.length === 0) {
|
||||
errors.name = 'Name is required';
|
||||
}
|
||||
}}
|
||||
onChange={(e) => {
|
||||
handleNameInput(e);
|
||||
setNameLength(e.target.value.length);
|
||||
@ -187,11 +182,6 @@ const Sidebar: React.FC<SidebarProps> = ({tierOptions,
|
||||
placeholder='Black Friday Special'
|
||||
title='Display title'
|
||||
value={overrides.displayTitle.value}
|
||||
onBlur={(e) => {
|
||||
if (!e.target.value && e.target.value.length === 0) {
|
||||
errors.displayTitle = 'Display title is required';
|
||||
}
|
||||
}}
|
||||
onChange={(e) => {
|
||||
handleDisplayTitleInput(e);
|
||||
}}
|
||||
@ -240,19 +230,6 @@ const Sidebar: React.FC<SidebarProps> = ({tierOptions,
|
||||
? (overrides.fixedAmount === 0 ? '' : overrides.fixedAmount?.toString())
|
||||
: (overrides.percentAmount === 0 ? '' : overrides.percentAmount?.toString())
|
||||
}
|
||||
onBlur={() => {
|
||||
if (overrides.type === 'percent' && overrides.percentAmount === 0) {
|
||||
errors.amount = 'Enter an amount greater than 0.';
|
||||
}
|
||||
|
||||
if (overrides.type === 'percent' && overrides.percentAmount && (overrides.percentAmount < 0 || overrides.percentAmount >= 100)) {
|
||||
errors.amount = 'Amount must be between 0 and 100%.';
|
||||
}
|
||||
|
||||
if (overrides.type === 'fixed' && overrides.fixedAmount && overrides.fixedAmount <= 0) {
|
||||
errors.amount = 'Enter an amount greater than 0.';
|
||||
}
|
||||
}}
|
||||
onChange={(e) => {
|
||||
handleAmountInput(e);
|
||||
}}
|
||||
@ -292,11 +269,6 @@ const Sidebar: React.FC<SidebarProps> = ({tierOptions,
|
||||
title='Trial duration'
|
||||
type='number'
|
||||
value={overrides.trialAmount?.toString()}
|
||||
onBlur={(e) => {
|
||||
if (Number(e.target.value) < 1) {
|
||||
errors.amount = 'Free trial must be at least 1 day.';
|
||||
}
|
||||
}}
|
||||
onChange={(e) => {
|
||||
handleTrialAmountInput(e);
|
||||
}}
|
||||
@ -310,11 +282,6 @@ const Sidebar: React.FC<SidebarProps> = ({tierOptions,
|
||||
placeholder='black-friday'
|
||||
title='Offer code'
|
||||
value={overrides.code.value}
|
||||
onBlur={(e) => {
|
||||
if (!e.target.value && e.target.value.length === 0) {
|
||||
errors.code = 'Code is required';
|
||||
}
|
||||
}}
|
||||
onChange={(e) => {
|
||||
handleCodeInput(e);
|
||||
}}
|
||||
|
@ -25,7 +25,7 @@ const Sidebar: React.FC<{
|
||||
errors: ErrorMessages,
|
||||
offer: Offer,
|
||||
updateOffer: (fields: Partial<Offer>) => void,
|
||||
validate: () => void}> = ({clearError, errors, offer, updateOffer, validate}) => {
|
||||
validate: () => void}> = ({clearError, errors, offer, updateOffer}) => {
|
||||
const {siteData} = useGlobalData();
|
||||
const [isCopied, setIsCopied] = useState(false);
|
||||
const handleError = useHandleError();
|
||||
@ -131,7 +131,6 @@ const Sidebar: React.FC<{
|
||||
placeholder='Black Friday'
|
||||
title='Offer name'
|
||||
value={offer?.name}
|
||||
onBlur={validate}
|
||||
onChange={(e) => {
|
||||
setNameLength(e.target.value.length);
|
||||
updateOffer({name: e.target.value});
|
||||
@ -156,7 +155,6 @@ const Sidebar: React.FC<{
|
||||
placeholder='black-friday'
|
||||
title='Offer code'
|
||||
value={offer?.code}
|
||||
onBlur={validate}
|
||||
onChange={e => updateOffer({code: e.target.value})}
|
||||
onKeyDown={() => clearError('name')}
|
||||
/>
|
||||
|
Loading…
Reference in New Issue
Block a user