fix advanced section collapsing after changing claim name

This commit is contained in:
Sean Yesmunt 2020-02-11 18:00:29 -05:00
parent 3ad923b4f8
commit f351c9eedf

View file

@ -74,6 +74,12 @@ function ModalRepost(props: Props) {
repostNameError = __('You already have a claim with this name.');
}
React.useEffect(() => {
if ((repostNameError || repostNameError) && !showAdvanced) {
setShowAdvanced(true);
}
}, [repostBidError, repostNameError, showAdvanced, setShowAdvanced]);
const channelStrings = channels && channels.map(channel => channel.permanent_url).join(',');
React.useEffect(() => {
if (!repostChannel && channelStrings) {
@ -111,7 +117,6 @@ function ModalRepost(props: Props) {
doHideModal();
}
const showAdvancedSection = showAdvanced || repostNameError || repostBidError;
return (
<Modal isOpen type="card" onAborted={handleCloseModal} onConfirmed={handleCloseModal}>
<Card
@ -137,13 +142,15 @@ function ModalRepost(props: Props) {
channel={repostChannel}
onChannelChange={newChannel => setRepostChannel(newChannel)}
/>
{!showAdvanced && (
<div className="section__actions">
{!showAdvancedSection && (
<Button button="link" label={__('Advanced')} onClick={() => setShowAdvanced(true)} />
)}
</div>
{showAdvancedSection && (
)}
{showAdvanced && (
<React.Fragment>
<fieldset-section>
<fieldset-group class="fieldset-group--smushed fieldset-group--disabled-prefix">
<fieldset-section>
<label>{__('Name')}</label>
@ -159,6 +166,8 @@ function ModalRepost(props: Props) {
onChange={event => setRepostName(event.target.value)}
/>
</fieldset-group>
</fieldset-section>
<div className="form-field__help">
<I18nMessage
tokens={{