Skip to content

Commit 5b8b621

Browse files
committed
Avoid text boxes in partially open drawer
1 parent 4f1a01d commit 5b8b621

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/components/entry/overview/ReportButton.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,27 @@ import { useSelector } from 'react-redux'
55

66
import { ReportModal } from '../../form/ReportModal'
77
import Button from '../../ui/Button'
8+
import useLocationPane from '../useLocationPane'
89

910
export const ReportButton = () => {
1011
const { location: locationData } = useSelector((state) => state.location)
1112
const { t } = useTranslation()
1213
const typesAccess = useSelector((state) => state.type.typesAccess)
14+
const { drawerFullyOpen, fullyOpenPaneDrawer } = useLocationPane()
1315

1416
const locationName = locationData?.type_ids
1517
.map((id) => typesAccess?.getType(id)?.commonName)
1618
.filter(Boolean)
1719
.join(', ')
1820
const [isReportModalOpen, setIsReportModalOpen] = useState(false)
1921

22+
const handleReportClick = () => {
23+
if (!drawerFullyOpen) {
24+
fullyOpenPaneDrawer()
25+
}
26+
setIsReportModalOpen(true)
27+
}
28+
2029
return (
2130
<>
2231
{isReportModalOpen && (
@@ -27,11 +36,7 @@ export const ReportButton = () => {
2736
onDismiss={() => setIsReportModalOpen(false)}
2837
/>
2938
)}
30-
<Button
31-
leftIcon={<Flag />}
32-
secondary
33-
onClick={() => setIsReportModalOpen(true)}
34-
>
39+
<Button leftIcon={<Flag />} secondary onClick={handleReportClick}>
3540
{t('form.button.report')}
3641
</Button>
3742
</>

src/components/entry/overview/SaveToListButton.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
import Button from '../../ui/Button'
1616
import { theme } from '../../ui/GlobalStyle'
1717
import Input from '../../ui/Input'
18+
import useLocationPane from '../useLocationPane'
1819
import useSavedLists from './useSavedLists'
1920

2021
const SkeletonItemRow = styled.div`
@@ -170,6 +171,7 @@ const SaveToListButton = ({ containerRef }) => {
170171
const addingNewSkeletonRef = useRef(null)
171172

172173
const { lists } = useSavedLists(locationId)
174+
const { drawerFullyOpen, fullyOpenPaneDrawer } = useLocationPane()
173175

174176
useEffect(() => {
175177
const handleClickOutside = (e) => {
@@ -212,6 +214,9 @@ const SaveToListButton = ({ containerRef }) => {
212214
}, [isAddingNew])
213215

214216
const handleButtonClick = () => {
217+
if (!drawerFullyOpen) {
218+
fullyOpenPaneDrawer()
219+
}
215220
if (!open) {
216221
dispatch(fetchLists())
217222
}

0 commit comments

Comments
 (0)