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!

Minor fixes

Blue Moused3244d97d8c4
diff --git a/web/app/modals/AnnotationModal.tsx b/web/app/modals/AnnotationModal.tsx
index 06b11c31d..d2b3341d6 100644
--- a/web/app/modals/AnnotationModal.tsx
+++ b/web/app/modals/AnnotationModal.tsx
@@ -1,4 +1,4 @@
-import { useState, useEffect, useMemo } from 'react'
+import { useState, useEffect, useMemo, useId } from 'react'
import { useTranslation } from 'react-i18next'
import { Annotation } from '~/lib/models/Project'
@@ -47,6 +47,8 @@ const AnnotationModal = ({
const [date, setDate] = useState(initialDate)
const [text, setText] = useState(initialText)
+ const dateInputId = useId()
+
useEffect(() => {
// eslint-disable-next-line react-hooks/set-state-in-effect -- Syncing initial state with UI
setDate(initialDate)
@@ -124,6 +126,7 @@ const AnnotationModal = ({
<div>
<Text
as='label'
+ htmlFor={dateInputId}
size='sm'
weight='medium'
colour='secondary'
@@ -134,6 +137,7 @@ const AnnotationModal = ({
</Text>
<Datepicker
mode='single'
+ inputId={dateInputId}
value={date ? [new Date(date + 'T00:00:00')] : []}
onChange={(dates) => {
if (dates.length > 0 && allowedToManage) {
diff --git a/web/app/pages/ErrorTracking/index.tsx b/web/app/pages/ErrorTracking/index.tsx
index 1b3dc56a1..027309a8c 100644
--- a/web/app/pages/ErrorTracking/index.tsx
+++ b/web/app/pages/ErrorTracking/index.tsx
@@ -154,11 +154,19 @@ const ErrorTracking = () => {
/>
</Text>
<ul className='mt-2 list-inside list-disc'>
- {_map(t('errors.fast.list', { returnObjects: true }), (item) => (
- <Text as='li' size='lg' key={item} className='mb-2'>
- {item}
- </Text>
- ))}
+ {_map(
+ t('errors.fast.list', { returnObjects: true }),
+ (item, idx) => (
+ <Text
+ as='li'
+ size='lg'
+ key={`error-fast-${idx}`}
+ className='mb-2'
+ >
+ {item}
+ </Text>
+ ),
+ )}
</ul>
<Text
diff --git a/web/app/pages/Organisations/Settings/People.tsx b/web/app/pages/Organisations/Settings/People.tsx
index 540d31c5b..95ebd4421 100644
--- a/web/app/pages/Organisations/Settings/People.tsx
+++ b/web/app/pages/Organisations/Settings/People.tsx
@@ -175,8 +175,11 @@ const UsersList = ({ members, onRemove, fetcher }: UsersListProps) => {
size='xs'
type='button'
onClick={() => onRemove(member)}
+ aria-label={t('project.settings.removeUser', {
+ user: member.user.email,
+ })}
>
- <TrashIcon className='h-4 w-4' />
+ <TrashIcon className='h-4 w-4' aria-hidden='true' />
</Button>
</div>
)}
diff --git a/web/app/pages/Project/View/components/RefreshStatsButton.tsx b/web/app/pages/Project/View/components/RefreshStatsButton.tsx
index e89386818..10ebcc2c2 100644
--- a/web/app/pages/Project/View/components/RefreshStatsButton.tsx
+++ b/web/app/pages/Project/View/components/RefreshStatsButton.tsx
@@ -54,12 +54,16 @@ export const RefreshStatsButton = ({ onRefresh }: RefreshStatsButtonProps) => {
hasTriggeredRefresh.current = true
;(async () => {
setIsRefreshing(true)
- await onRefresh(false)
- setIsRefreshing(false)
- // Reset timer after refresh completes
- startTimeRef.current = Date.now()
- hasTriggeredRefresh.current = false
- setProgress(0)
+ try {
+ await onRefresh(false)
+ } catch (error) {
+ console.error('Auto refresh failed', error)
+ } finally {
+ setIsRefreshing(false)
+ startTimeRef.current = Date.now()
+ hasTriggeredRefresh.current = false
+ setProgress(0)
+ }
})()
}
@@ -77,8 +81,11 @@ export const RefreshStatsButton = ({ onRefresh }: RefreshStatsButtonProps) => {
startTimeRef.current = Date.now()
hasTriggeredRefresh.current = false
setProgress(0)
- await onRefresh(true)
- setIsRefreshing(false)
+ try {
+ await onRefresh(true)
+ } finally {
+ setIsRefreshing(false)
+ }
}
const remainingSeconds = Math.max(
diff --git a/web/app/root.tsx b/web/app/root.tsx
index 10e4b2f9b..2f352e7ba 100644
--- a/web/app/root.tsx
+++ b/web/app/root.tsx
@@ -255,6 +255,8 @@ export function ErrorBoundary() {
<button
type='button'
onClick={() => setCrashStackShown((prev) => !prev)}
+ aria-expanded={crashStackShown}
+ aria-controls='crash-stack'
className='flex cursor-pointer items-center justify-center text-base text-gray-800 hover:underline dark:text-gray-300'
>
{crashStackShown ? (
@@ -270,7 +272,11 @@ export function ErrorBoundary() {
)}
</button>
{crashStackShown ? (
- <span className='text-sm whitespace-pre-line text-gray-600 dark:text-gray-400'>
+ <span
+ id='crash-stack'
+ role='region'
+ className='text-sm whitespace-pre-line text-gray-600 dark:text-gray-400'
+ >
{error.stack}
</span>
) : null}
diff --git a/web/app/routes/_index.tsx b/web/app/routes/_index.tsx
index 0a4064dea..da1a1b6aa 100644
--- a/web/app/routes/_index.tsx
+++ b/web/app/routes/_index.tsx
@@ -332,7 +332,7 @@ const LiveDemoPreview = () => {
style={{ pointerEvents: 'none' }}
tabIndex={-1}
/>
- <div className='pointer-events-none absolute inset-0 flex items-center justify-center rounded-2xl bg-slate-900/40 opacity-0 backdrop-blur-[2px] transition-opacity duration-200 group-hover:pointer-events-auto group-hover:opacity-100'>
+ <div className='pointer-events-none absolute inset-0 flex items-center justify-center rounded-2xl bg-slate-900/40 opacity-0 backdrop-blur-[2px] transition-opacity duration-200 group-focus-within:pointer-events-auto group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100'>
<a
href={LIVE_DEMO_URL}
target='_blank'
diff --git a/web/app/routes/tools.meta-tags-generator.tsx b/web/app/routes/tools.meta-tags-generator.tsx
index 6cc513f1a..0b37731a2 100644
--- a/web/app/routes/tools.meta-tags-generator.tsx
+++ b/web/app/routes/tools.meta-tags-generator.tsx
@@ -71,6 +71,15 @@ interface MetaData {
twitterHandle: string
}
+const getHostnameFromUrl = (url: string): string => {
+ if (!url) return 'example.com'
+ try {
+ return new URL(url.startsWith('http') ? url : `https://${url}`).hostname
+ } catch {
+ return 'example.com'
+ }
+}
+
export default function MetaTagsGenerator() {
const [data, setData] = useState<MetaData>({
title: 'Swetrix - Privacy-focused web analytics',
@@ -274,13 +283,7 @@ ${imageUrl ? `<meta property="twitter:image" content="${imageUrl}" />\n` : ''}${
)}
<div className='border-t border-gray-200 p-3 dark:border-slate-800'>
<Text as='p' size='sm' colour='muted' className='truncate'>
- {data.url
- ? new URL(
- data.url.startsWith('http')
- ? data.url
- : `https://${data.url}`,
- ).hostname
- : 'example.com'}
+ {getHostnameFromUrl(data.url)}
</Text>
<Text as='p' weight='semibold' className='mt-0.5 truncate'>
{data.title || 'Page Title'}
diff --git a/web/app/ui/Datepicker.tsx b/web/app/ui/Datepicker.tsx
index f39206d91..21134bc22 100644
--- a/web/app/ui/Datepicker.tsx
+++ b/web/app/ui/Datepicker.tsx
@@ -25,6 +25,8 @@ interface DatePickerProps {
maxRange?: number
className?: string
mode?: 'single' | 'range'
+ inputId?: string
+ ariaLabelledBy?: string
}
type DatePickerHandle = {
@@ -109,6 +111,8 @@ const DatePicker = forwardRef<DatePickerHandle, DatePickerProps>(
maxRange = 0,
className,
mode = 'range',
+ inputId,
+ ariaLabelledBy,
},
ref,
) {
@@ -340,6 +344,8 @@ const DatePicker = forwardRef<DatePickerHandle, DatePickerProps>(
{options ? (
<input
readOnly
+ id={inputId}
+ aria-labelledby={ariaLabelledBy}
onClick={() => setOpen(true)}
value={label || ''}
placeholder={
diff --git a/web/app/ui/MultiSelect.tsx b/web/app/ui/MultiSelect.tsx
index 814e9cf93..4822d554e 100644
--- a/web/app/ui/MultiSelect.tsx
+++ b/web/app/ui/MultiSelect.tsx
@@ -138,7 +138,7 @@ const MultiSelect = ({
const activeOptionId =
activeIndex >= 0 && items[activeIndex]
- ? `${optionIdPrefix}-${itemKey(items[activeIndex])}`
+ ? `${optionIdPrefix}-${activeIndex}`
: undefined
return (
@@ -189,7 +189,7 @@ const MultiSelect = ({
_map(items, (item, index) => {
const isSelected = _includes(label, item)
const isActive = index === activeIndex
- const optionId = `${optionIdPrefix}-${itemKey(item)}`
+ const optionId = `${optionIdPrefix}-${index}`
return (
<button
type='button'
diff --git a/web/app/ui/ProgressRing.tsx b/web/app/ui/ProgressRing.tsx
index f7077fb5a..0cec40e24 100644
--- a/web/app/ui/ProgressRing.tsx
+++ b/web/app/ui/ProgressRing.tsx
@@ -83,7 +83,8 @@ const ProgressRing = ({
)
const center = size / 2
- const displayValue = Math.floor(normalizedValue)
+ const isFinite = Number.isFinite(normalizedValue)
+ const displayValue = isFinite ? Math.floor(normalizedValue) : 0
return (
<div
@@ -94,7 +95,7 @@ const ProgressRing = ({
role='progressbar'
aria-valuemin={0}
aria-valuemax={100}
- aria-valuenow={displayValue}
+ aria-valuenow={isFinite ? displayValue : undefined}
aria-label={ariaLabel ?? `Progress: ${displayValue}%`}
>
<svg width={size} height={size} className='-rotate-90' aria-hidden='true'>