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

fix: clear field error in Editor after the field value is changed #7216

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: add ControlTopbar for correct error display at widget
  • Loading branch information
olegfedak committed May 28, 2024
commit 06062a4c19a031c6bc1aaf3c39433af9a16e1cce
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,26 @@ const ControlContainer = styled.div`
}
`;

const ControlTopbar = styled.div`
display: flex;
justify-content: space-between;
gap: 20px;
align-items: end;
`;
const ControlErrorsList = styled.ul`
list-style-type: none;
font-size: 12px;
color: ${colors.errorText};
margin-bottom: 5px;
text-align: right;
text-transform: uppercase;
position: relative;
font-weight: 600;
top: 20px;
margin: 0;
padding: 2px 0 3px;
`;

export const ControlHint = styled.p`
margin-bottom: 0;
padding: 6px 6px 0;
padding: 6px 0 0;
font-size: 12px;
color: ${props =>
props.error ? colors.errorText : props.active ? colors.active : colors.controlLabel};
Expand Down Expand Up @@ -240,28 +245,30 @@ class EditorControl extends React.Component {
${isHidden && styleStrings.hidden};
`}
>
{widget.globalStyles && <Global styles={coreCss`${widget.globalStyles}`} />}
{errors && (
<ControlErrorsList>
{errors.map(
error =>
error.message &&
typeof error.message === 'string' && (
<li key={error.message.trim().replace(/[^a-z0-9]+/gi, '-')}>
{error.message}
</li>
),
)}
</ControlErrorsList>
)}
<LabelComponent
field={field}
isActive={isSelected || this.state.styleActive}
hasErrors={hasErrors}
uniqueFieldId={this.uniqueFieldId}
isFieldOptional={isFieldOptional}
t={t}
/>
<ControlTopbar>
{widget.globalStyles && <Global styles={coreCss`${widget.globalStyles}`} />}
<LabelComponent
field={field}
isActive={isSelected || this.state.styleActive}
hasErrors={hasErrors}
uniqueFieldId={this.uniqueFieldId}
isFieldOptional={isFieldOptional}
t={t}
/>
{errors && (
<ControlErrorsList>
{errors.map(
error =>
error.message &&
typeof error.message === 'string' && (
<li key={error.message.trim().replace(/[^a-z0-9]+/gi, '-')}>
{error.message}
</li>
),
)}
</ControlErrorsList>
)}
</ControlTopbar>
<Widget
classNameWrapper={cx(
css`
Expand Down
Loading