From 101f411d1f6cf1c5973aa1e551fe2b535637a37c Mon Sep 17 00:00:00 2001 From: Amberroseweeks Date: Fri, 8 Nov 2024 23:43:12 -0500 Subject: [PATCH 1/2] updating filter button label --- src/components/SidePanelControlBar.tsx | 1 + src/components/ThemeButton.tsx | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/SidePanelControlBar.tsx b/src/components/SidePanelControlBar.tsx index 73a01184..dac7c859 100644 --- a/src/components/SidePanelControlBar.tsx +++ b/src/components/SidePanelControlBar.tsx @@ -116,6 +116,7 @@ const SearchBarComponent: FC = ({ ? 'Filter' : `Filter ${filterCount} filters active` } + aria-expanded={currentView === 'filter'} label={
Filter diff --git a/src/components/ThemeButton.tsx b/src/components/ThemeButton.tsx index d413bd2f..15c5a14d 100644 --- a/src/components/ThemeButton.tsx +++ b/src/components/ThemeButton.tsx @@ -7,6 +7,7 @@ type ButtonProps = Omit & { label?: string | React.ReactNode; color?: 'primary' | 'secondary' | 'tertiary'; isSelected?: boolean; + ariaCurrent?: boolean; }; type Ref = HTMLButtonElement; @@ -93,6 +94,7 @@ const ThemeButton = forwardRef(function ThemeButton( ? `cursor-not-allowed ${removedTransitionStyles}` : ''; const iconStyles = 'w-5 h-5 text-xl'; + const ariaCurrent = isSelected ? { 'aria-current': 'true' } : {}; return ( (function ThemeButton( className={`${basedStyles} ${colorStyles} ${padding} ${disabledStyles} ${className}`} ref={ref} aria-disabled={isDisabled} - aria-current={isSelected ? 'true' : undefined} + ariaCurrent startContent={ startContent ? ( {startContent} From 0aaeccf475a331d755a51407028880760dd589f9 Mon Sep 17 00:00:00 2001 From: Amberroseweeks Date: Sat, 16 Nov 2024 16:39:16 -0500 Subject: [PATCH 2/2] updating filter button and focus handling --- src/components/FilterView.tsx | 12 +++++++++--- src/components/SidePanelControlBar.tsx | 22 ++++++++++++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/components/FilterView.tsx b/src/components/FilterView.tsx index f0745f8c..34e6ebfd 100644 --- a/src/components/FilterView.tsx +++ b/src/components/FilterView.tsx @@ -1,9 +1,11 @@ +'use client'; + import { FC } from 'react'; -import DimensionFilter from './Filters/DimensionFilter'; import { PiX } from 'react-icons/pi'; -import { BarClickOptions } from '@/app/find-properties/[[...opa_id]]/page'; import { ThemeButton } from './ThemeButton'; +import { BarClickOptions } from '@/app/find-properties/[[...opa_id]]/page'; import { rcos, neighborhoods, zoning } from './Filters/filterOptions'; +import DimensionFilter from './Filters/DimensionFilter'; const filters = [ { @@ -59,12 +61,16 @@ interface FilterViewProps { const FilterView: FC = ({ updateCurrentView }) => { return (
+ {/* Add ID to the close button */} } - onPress={() => updateCurrentView('filter')} + id="close-filter-button" // Add an ID to this button + onPress={() => { + updateCurrentView('filter'); + }} /> {filters.map((attr) => ( diff --git a/src/components/SidePanelControlBar.tsx b/src/components/SidePanelControlBar.tsx index dac7c859..60d90aac 100644 --- a/src/components/SidePanelControlBar.tsx +++ b/src/components/SidePanelControlBar.tsx @@ -1,11 +1,12 @@ 'use client'; -import React, { FC, useMemo, useRef } from 'react'; +import React, { FC, useMemo, useRef, useEffect } from 'react'; import { BarClickOptions } from '@/app/find-properties/[[...opa_id]]/page'; import { BookmarkSimple, DownloadSimple, Funnel } from '@phosphor-icons/react'; import { ThemeButton } from './ThemeButton'; import { useFilter } from '@/context/FilterContext'; import { getPropertyIdsFromLocalStorage } from '@/utilities/localStorage'; +import FilterView from './FilterView'; // Import the FilterView component type SidePanelControlBarProps = { currentView: string; @@ -30,7 +31,10 @@ const SearchBarComponent: FC = ({ }) => { const filterRef = useRef(null); const savedRef = useRef(null); + const filterfocusRef = useRef(null); + const { dispatch, appFilter } = useFilter(); + const filterViewRef = useRef(null); // Reference for the FilterView component const filterCount: number = useMemo(() => { let count = 0; @@ -67,6 +71,17 @@ const SearchBarComponent: FC = ({ } }; + // Focus the "X" button inside FilterView after filter is expanded + useEffect(() => { + if (currentView === 'filter') { + // Focus the "X" button inside FilterView using its ID + const closeButton = document.getElementById('close-filter-button'); + if (closeButton) { + closeButton.focus(); + } + } + }); + return loading ? (
{/* Keep empty while loading */}
) : ( @@ -125,7 +140,10 @@ const SearchBarComponent: FC = ({ )}
} - onPress={() => updateCurrentView('filter')} + onPress={() => { + updateCurrentView('filter'); + filterfocusRef.current?.focus(); // Focus the filter button after pressing + }} isSelected={currentView === 'filter' || filterCount !== 0} startContent={} className="max-lg:min-w-[4rem]"