From 287a2eb8ed1dd8400a9799564df365f9b66d2ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20=C5=BBegle=C5=84?= Date: Thu, 1 Oct 2020 17:50:17 +0200 Subject: [PATCH] Hide save bar if no action is available (#735) --- .../AttributePage/AttributePage.tsx | 4 +- .../SaveButtonBar/SaveButtonBar.tsx | 83 ++++++++++--------- .../CountryListPage/CountryListPage.tsx | 4 +- 3 files changed, 47 insertions(+), 44 deletions(-) diff --git a/src/attributes/components/AttributePage/AttributePage.tsx b/src/attributes/components/AttributePage/AttributePage.tsx index 9fe12bdb0..2e4bb018a 100644 --- a/src/attributes/components/AttributePage/AttributePage.tsx +++ b/src/attributes/components/AttributePage/AttributePage.tsx @@ -136,7 +136,7 @@ const AttributePage: React.FC = ({ return (
- {({ change, data, submit }) => { + {({ change, data, hasChanged, submit }) => { const changeMetadata = makeMetadataChangeHandler(change); return ( @@ -185,7 +185,7 @@ const AttributePage: React.FC = ({ = props => { const scrollPosition = useWindowScroll(); const scrolledToBottom = scrollPosition.y + window.innerHeight >= document.body.scrollHeight; + const shouldDisplay = onDelete || !disabled; return ( {anchor => anchor ? ( -
- - - - {!!onDelete && ( + {shouldDisplay && ( +
+ + + + {!!onDelete && ( + + )} +
- )} -
- - - {maybe( - () => labels.save, - intl.formatMessage(buttonMessages.save) - )} - - - - -
+ + {maybe( + () => labels.save, + intl.formatMessage(buttonMessages.save) + )} + + + + +
+ )} ) : null } diff --git a/src/taxes/components/CountryListPage/CountryListPage.tsx b/src/taxes/components/CountryListPage/CountryListPage.tsx index 42680f1c7..1576ff4f6 100644 --- a/src/taxes/components/CountryListPage/CountryListPage.tsx +++ b/src/taxes/components/CountryListPage/CountryListPage.tsx @@ -47,7 +47,7 @@ const CountryListPage: React.FC = ({ }; return ( - {({ change, data, submit }) => ( + {({ change, data, hasChanged, submit }) => ( <> @@ -77,7 +77,7 @@ const CountryListPage: React.FC = ({