Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fixed broken dashboard checkboxes

Blue Mouse4bd39b534e3f
diff --git a/app/pages/Project/View/ViewProject.tsx b/app/pages/Project/View/ViewProject.tsx
index 55c61dc4a..363950dfe 100644
--- a/app/pages/Project/View/ViewProject.tsx
+++ b/app/pages/Project/View/ViewProject.tsx
@@ -938,18 +938,31 @@ const ViewProject = ({
// activeTabLabel is a label for active tab. Using for title in dropdown
const activeTabLabel = useMemo(() => _find(tabs, (tab) => tab.id === activeTab)?.label, [tabs, activeTab])
- // switchActiveChartMetric is a function for change activeChartMetrics
- // eslint-disable-next-line react-hooks/exhaustive-deps
- const switchActiveChartMetric = useCallback(
- _debounce((pairID) => {
- if (activeTab === PROJECT_TABS.performance) {
- setActiveChartMetricsPerf(pairID)
+ const switchTrafficChartMetric = (pairID: string, conflicts: string[]) => {
+ if (isConflicted(conflicts)) {
+ generateAlert(t('project.conflictMetric'), 'error')
+ return
+ }
+
+ if (pairID === CHART_METRICS_MAPPING.customEvents) {
+ return
+ }
+
+ setActiveChartMetrics((prev) => ({ ...prev, [pairID]: !prev[pairID] }))
+ }
+
+ const switchCustomEventChart = (id: string) => {
+ setActiveChartMetricsCustomEvents((prev) => {
+ const newActiveChartMetricsCustomEvents = [...prev]
+ const index = _findIndex(prev, (item) => item === id)
+ if (index === -1) {
+ newActiveChartMetricsCustomEvents.push(id)
} else {
- setActiveChartMetrics((prev) => ({ ...prev, [pairID]: !prev[pairID] }))
+ newActiveChartMetricsCustomEvents.splice(index, 1)
}
- }, 0),
- [activeTab],
- )
+ return newActiveChartMetricsCustomEvents
+ })
+ }
// eslint-disable-next-line react-hooks/exhaustive-deps
const switchActiveErrorFilter = useCallback(
@@ -3720,7 +3733,9 @@ const ViewProject = ({
event.label
)
}
- onChange={() => {}}
+ onChange={() => {
+ switchCustomEventChart(event.id)
+ }}
checked={event.active}
/>
)}
@@ -3730,17 +3745,9 @@ const ViewProject = ({
e?.stopPropagation()
e?.preventDefault()
- setActiveChartMetricsCustomEvents((prev) => {
- const newActiveChartMetricsCustomEvents = [...prev]
- const index = _findIndex(prev, (item) => item === event.id)
- if (index === -1) {
- newActiveChartMetricsCustomEvents.push(event.id)
- } else {
- newActiveChartMetricsCustomEvents.splice(index, 1)
- }
- return newActiveChartMetricsCustomEvents
- })
+ switchCustomEventChart(event.id)
}}
+ chevron='mini'
headless
/>
)
@@ -3752,22 +3759,16 @@ const ViewProject = ({
label={label}
disabled={conflicted}
checked={active}
+ onChange={() => {
+ switchTrafficChartMetric(pairID, conflicts)
+ }}
/>
)
}}
selectItemClassName='group text-gray-700 dark:text-gray-50 dark:border-gray-800 dark:bg-slate-800 block text-sm cursor-pointer hover:bg-gray-200 dark:hover:bg-slate-700'
keyExtractor={(pair) => pair.id}
onSelect={({ id: pairID, conflicts }) => {
- if (isConflicted(conflicts)) {
- generateAlert(t('project.conflictMetric'), 'error')
- return
- }
-
- if (pairID === CHART_METRICS_MAPPING.customEvents) {
- return
- }
-
- switchActiveChartMetric(pairID)
+ switchTrafficChartMetric(pairID, conflicts)
}}
chevron='mini'
headless
@@ -3812,9 +3813,16 @@ const ViewProject = ({
items={errorFilters}
title={t('project.filters')}
labelExtractor={(pair) => {
- const { label, active } = pair
+ const { label, active, id: pairID } = pair
- return <Checkbox className='px-4 py-2' label={label} checked={active} />
+ return (
+ <Checkbox
+ className='px-4 py-2'
+ label={label}
+ checked={active}
+ onChange={() => switchActiveErrorFilter(pairID)}
+ />
+ )
}}
selectItemClassName='group text-gray-700 dark:text-gray-50 dark:border-gray-800 dark:bg-slate-800 block text-sm cursor-pointer hover:bg-gray-200 dark:hover:bg-slate-700'
keyExtractor={(pair) => pair.id}
@@ -3855,7 +3863,7 @@ const ViewProject = ({
labelExtractor={(pair) => pair.label}
keyExtractor={(pair) => pair.id}
onSelect={({ id: pairID }) => {
- switchActiveChartMetric(pairID)
+ setActiveChartMetricsPerf(pairID)
}}
chevron='mini'
headless
diff --git a/app/pages/Project/View/components/TBPeriodSelector.tsx b/app/pages/Project/View/components/TBPeriodSelector.tsx
index b1e82bb17..541dec3d5 100644
--- a/app/pages/Project/View/components/TBPeriodSelector.tsx
+++ b/app/pages/Project/View/components/TBPeriodSelector.tsx
@@ -43,70 +43,79 @@ const TBPeriodSelector = ({
return (
<Popover className='relative'>
- <PopoverButton className='group inline-flex w-full px-3 py-2 text-sm font-medium text-gray-700 outline-none dark:text-gray-50 md:px-4'>
- <CalendarDaysIcon className='mr-1 h-5 w-5' />
- <span>{title}</span>
- <ChevronDownIcon
- className='ml-2 h-5 w-5 text-gray-700 transition duration-150 ease-in-out group-hover:text-gray-500 dark:text-gray-50'
- aria-hidden='true'
- />
- </PopoverButton>
- <Transition
- as={Fragment}
- enter='transition ease-out duration-200'
- enterFrom='opacity-0 translate-y-1'
- enterTo='opacity-100 translate-y-0'
- leave='transition ease-in duration-150'
- leaveFrom='opacity-100 translate-y-0'
- leaveTo='opacity-0 translate-y-1'
- >
- {/* w-56 */}
- <PopoverPanel className='absolute left-1/2 right-0 z-20 mt-3 w-max max-w-sm -translate-x-1/2 transform px-4 sm:px-0 md:left-auto md:transform-none lg:max-w-3xl'>
- <div className='overflow-hidden rounded-lg bg-gray-50 p-1 shadow-lg ring-1 ring-black/5 dark:bg-slate-800'>
- <div
+ {({ open }) => (
+ <>
+ <PopoverButton className='group inline-flex w-full px-3 py-2 text-sm font-medium text-gray-700 outline-none dark:text-gray-50 md:px-4'>
+ <CalendarDaysIcon className='mr-1 h-5 w-5' />
+ <span>{title}</span>
+ <ChevronDownIcon
className={cx(
- 'relative z-0 mb-1 flex items-center space-x-5 rounded-md bg-slate-200 px-2 py-3 dark:bg-slate-700',
- classes?.timeBucket,
+ 'ml-2 h-5 w-5 transform-gpu text-gray-700 transition duration-150 ease-in-out group-hover:text-gray-500 dark:text-gray-50',
+ {
+ 'rotate-180': open,
+ },
)}
- >
- {_map(periods, ({ label, value, available }) => (
- <PopoverButton
- key={value}
- type='button'
- onClick={() => {
- if (!available || timeBucket === value) {
- return
- }
-
- updateTimebucket(value)
- }}
- className={cx('relative inline-flex items-center text-sm font-medium capitalize', {
- 'text-gray-900 dark:text-gray-50': timeBucket === value,
- 'text-gray-700 dark:text-gray-300': available && timeBucket !== value,
- 'text-gray-400 dark:text-gray-500': !available && timeBucket !== value,
- 'cursor-pointer': available,
- 'cursor-default': !available,
- })}
- >
- {label}
- </PopoverButton>
- ))}
- </div>
- <ul className={cx('w-full text-left', classes?.periods)}>
- {_map(items, (item) => (
- <PopoverButton
- as='li'
- key={item.label}
- onClick={(e: React.MouseEvent<HTMLElement>) => onSelect(item, e)}
- className='block cursor-pointer rounded-md px-4 py-2 text-sm text-gray-700 hover:bg-gray-200 dark:text-gray-50 dark:hover:bg-slate-700'
+ aria-hidden='true'
+ />
+ </PopoverButton>
+ <Transition
+ as={Fragment}
+ enter='transition ease-out duration-200'
+ enterFrom='opacity-0 translate-y-1'
+ enterTo='opacity-100 translate-y-0'
+ leave='transition ease-in duration-150'
+ leaveFrom='opacity-100 translate-y-0'
+ leaveTo='opacity-0 translate-y-1'
+ >
+ {/* w-56 */}
+ <PopoverPanel className='absolute left-1/2 right-0 z-20 mt-3 w-max max-w-sm -translate-x-1/2 transform px-4 sm:px-0 md:left-auto md:transform-none lg:max-w-3xl'>
+ <div className='overflow-hidden rounded-lg bg-gray-50 p-1 shadow-lg ring-1 ring-black/5 dark:bg-slate-800'>
+ <div
+ className={cx(
+ 'relative z-0 mb-1 flex items-center space-x-5 rounded-md bg-slate-200 px-2 py-3 dark:bg-slate-700',
+ classes?.timeBucket,
+ )}
>
- {item.dropdownLabel || item.label}
- </PopoverButton>
- ))}
- </ul>
- </div>
- </PopoverPanel>
- </Transition>
+ {_map(periods, ({ label, value, available }) => (
+ <PopoverButton
+ key={value}
+ type='button'
+ onClick={() => {
+ if (!available || timeBucket === value) {
+ return
+ }
+
+ updateTimebucket(value)
+ }}
+ className={cx('relative inline-flex items-center text-sm font-medium capitalize', {
+ 'text-gray-900 dark:text-gray-50': timeBucket === value,
+ 'text-gray-700 dark:text-gray-300': available && timeBucket !== value,
+ 'text-gray-400 dark:text-gray-500': !available && timeBucket !== value,
+ 'cursor-pointer': available,
+ 'cursor-default': !available,
+ })}
+ >
+ {label}
+ </PopoverButton>
+ ))}
+ </div>
+ <ul className={cx('w-full text-left', classes?.periods)}>
+ {_map(items, (item) => (
+ <PopoverButton
+ as='li'
+ key={item.label}
+ onClick={(e: React.MouseEvent<HTMLElement>) => onSelect(item, e)}
+ className='block cursor-pointer rounded-md px-4 py-2 text-sm text-gray-700 hover:bg-gray-200 dark:text-gray-50 dark:hover:bg-slate-700'
+ >
+ {item.dropdownLabel || item.label}
+ </PopoverButton>
+ ))}
+ </ul>
+ </div>
+ </PopoverPanel>
+ </Transition>
+ </>
+ )}
</Popover>
)
}
diff --git a/app/ui/Dropdown.tsx b/app/ui/Dropdown.tsx
index 8f44d6b87..a0f05c062 100644
--- a/app/ui/Dropdown.tsx
+++ b/app/ui/Dropdown.tsx
@@ -66,16 +66,18 @@ const Dropdown = ({
{title}
{chevron === 'regular' && (
<ChevronDownIcon
- className={cx('-mr-1 ml-2 h-5 w-5', {
+ className={cx('-mr-1 ml-2 h-5 w-5 transform-gpu transition-transform', {
'group-hover:text-gray-500': headless,
+ 'rotate-180': open,
})}
aria-hidden='true'
/>
)}
{chevron === 'mini' && (
<ChevronDownIconMini
- className={cx('-mr-1 ml-1 h-5 w-5', {
+ className={cx('-mr-1 ml-1 h-5 w-5 transform-gpu transition-transform', {
'group-hover:text-gray-500': headless,
+ 'rotate-180': open,
})}
aria-hidden='true'
/>