refactor(a11y/combosearch): every combo with screen reader better support
This commit is contained in:
parent
71d43e9591
commit
3f15647b8e
9 changed files with 42 additions and 11 deletions
|
@ -1,3 +1,2 @@
|
||||||
class EditableChamp::AnnuaireEducationComponent < EditableChamp::EditableChampBaseComponent
|
class EditableChamp::AnnuaireEducationComponent < EditableChamp::ComboSearchComponent
|
||||||
include ApplicationHelper
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
- render_parent
|
||||||
|
|
||||||
= @form.hidden_field :value
|
= @form.hidden_field :value
|
||||||
= @form.hidden_field :external_id
|
= @form.hidden_field :external_id
|
||||||
= react_component("ComboAnnuaireEducationSearch",
|
= react_component("ComboAnnuaireEducationSearch",
|
||||||
required: @champ.required?,
|
required: @champ.required?,
|
||||||
id: @champ.input_id,
|
id: @champ.input_id,
|
||||||
describedby: @champ.describedby_id)
|
describedby: @champ.describedby_id,
|
||||||
|
**react_combo_props)
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
class EditableChamp::CarteComponent < EditableChamp::EditableChampBaseComponent
|
class EditableChamp::CarteComponent < EditableChamp::EditableChampBaseComponent
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
|
def initialize(**args)
|
||||||
|
super(**args)
|
||||||
|
|
||||||
|
@autocomplete_component = EditableChamp::ComboSearchComponent.new(**args)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
= react_component("MapEditor", featureCollection: @champ.to_feature_collection, url: champs_carte_features_path(@champ), options: @champ.render_options)
|
= render @autocomplete_component
|
||||||
|
|
||||||
|
= react_component("MapEditor",
|
||||||
|
featureCollection: @champ.to_feature_collection,
|
||||||
|
url: champs_carte_features_path(@champ),
|
||||||
|
options: @champ.render_options,
|
||||||
|
autocompleteAnnounceTemplateId: @autocomplete_component.announce_template_id,
|
||||||
|
autocompleteScreenReaderInstructions: t("combo_search_component.screen_reader_instructions"))
|
||||||
|
|
||||||
.geo-areas{ id: dom_id(@champ, :geo_areas) }
|
.geo-areas{ id: dom_id(@champ, :geo_areas) }
|
||||||
= render partial: 'shared/champs/carte/geo_areas', locals: { champ: @champ, editing: true }
|
= render partial: 'shared/champs/carte/geo_areas', locals: { champ: @champ, editing: true }
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
class EditableChamp::CommunesComponent < EditableChamp::EditableChampBaseComponent
|
class EditableChamp::CommunesComponent < EditableChamp::ComboSearchComponent
|
||||||
include ApplicationHelper
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
- render_parent
|
||||||
= @form.hidden_field :value
|
= @form.hidden_field :value
|
||||||
= @form.hidden_field :external_id
|
= @form.hidden_field :external_id
|
||||||
= @form.hidden_field :departement
|
= @form.hidden_field :departement
|
||||||
|
@ -7,4 +8,5 @@
|
||||||
id: @champ.input_id,
|
id: @champ.input_id,
|
||||||
classNameDepartement: "width-33-desktop width-100-mobile",
|
classNameDepartement: "width-33-desktop width-100-mobile",
|
||||||
className: "width-66-desktop width-100-mobile",
|
className: "width-66-desktop width-100-mobile",
|
||||||
describedby: @champ.describedby_id)
|
describedby: @champ.describedby_id,
|
||||||
|
**react_combo_props)
|
||||||
|
|
|
@ -24,7 +24,7 @@ type TransformResult<Result> = (
|
||||||
result: Result
|
result: Result
|
||||||
) => [key: string, value: string, label?: string];
|
) => [key: string, value: string, label?: string];
|
||||||
|
|
||||||
export type ComboSearchProps<Result> = {
|
export type ComboSearchProps<Result = unknown> = {
|
||||||
onChange?: (value: string | null, result?: Result) => void;
|
onChange?: (value: string | null, result?: Result) => void;
|
||||||
value?: string;
|
value?: string;
|
||||||
scope: string;
|
scope: string;
|
||||||
|
|
|
@ -2,8 +2,14 @@ import React from 'react';
|
||||||
import { fire } from '@utils';
|
import { fire } from '@utils';
|
||||||
|
|
||||||
import ComboAdresseSearch from '../../ComboAdresseSearch';
|
import ComboAdresseSearch from '../../ComboAdresseSearch';
|
||||||
|
import { ComboSearchProps } from '~/components/ComboSearch';
|
||||||
|
|
||||||
export function AddressInput() {
|
export function AddressInput(
|
||||||
|
comboProps: Pick<
|
||||||
|
ComboSearchProps,
|
||||||
|
'screenReaderInstructions' | 'announceTemplateId'
|
||||||
|
>
|
||||||
|
) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
|
@ -17,6 +23,7 @@ export function AddressInput() {
|
||||||
onChange={(_, feature) => {
|
onChange={(_, feature) => {
|
||||||
fire(document, 'map:zoom', { feature });
|
fire(document, 'map:zoom', { feature });
|
||||||
}}
|
}}
|
||||||
|
{...comboProps}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,15 +12,20 @@ import { AddressInput } from './components/AddressInput';
|
||||||
import { PointInput } from './components/PointInput';
|
import { PointInput } from './components/PointInput';
|
||||||
import { ImportFileInput } from './components/ImportFileInput';
|
import { ImportFileInput } from './components/ImportFileInput';
|
||||||
import { FlashMessage } from '../shared/FlashMessage';
|
import { FlashMessage } from '../shared/FlashMessage';
|
||||||
|
import { ComboSearchProps } from '../ComboSearch';
|
||||||
|
|
||||||
export default function MapEditor({
|
export default function MapEditor({
|
||||||
featureCollection: initialFeatureCollection,
|
featureCollection: initialFeatureCollection,
|
||||||
url,
|
url,
|
||||||
options
|
options,
|
||||||
|
autocompleteAnnounceTemplateId,
|
||||||
|
autocompleteScreenReaderInstructions
|
||||||
}: {
|
}: {
|
||||||
featureCollection: FeatureCollection;
|
featureCollection: FeatureCollection;
|
||||||
url: string;
|
url: string;
|
||||||
options: { layers: string[] };
|
options: { layers: string[] };
|
||||||
|
autocompleteAnnounceTemplateId: ComboSearchProps['announceTemplateId'];
|
||||||
|
autocompleteScreenReaderInstructions: ComboSearchProps['screenReaderInstructions'];
|
||||||
}) {
|
}) {
|
||||||
const [cadastreEnabled, setCadastreEnabled] = useState(false);
|
const [cadastreEnabled, setCadastreEnabled] = useState(false);
|
||||||
|
|
||||||
|
@ -46,7 +51,10 @@ export default function MapEditor({
|
||||||
{error && <FlashMessage message={error} level="alert" fixed={true} />}
|
{error && <FlashMessage message={error} level="alert" fixed={true} />}
|
||||||
|
|
||||||
<ImportFileInput featureCollection={featureCollection} {...actions} />
|
<ImportFileInput featureCollection={featureCollection} {...actions} />
|
||||||
<AddressInput />
|
<AddressInput
|
||||||
|
screenReaderInstructions={autocompleteScreenReaderInstructions}
|
||||||
|
announceTemplateId={autocompleteAnnounceTemplateId}
|
||||||
|
/>
|
||||||
|
|
||||||
<MapLibre layers={options.layers}>
|
<MapLibre layers={options.layers}>
|
||||||
<DrawLayer
|
<DrawLayer
|
||||||
|
|
Loading…
Reference in a new issue