Skip to content

Commit eba88c2

Browse files
committed
fix: add i18n props and delete onFocus
1 parent a1fb24d commit eba88c2

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/components/RelativeRangeDatePicker/__stories__/RelativeRangeDatePiker.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export const CustomControl: StoryObj<RelativeRangeDatePickerProps> = {
132132
{...props}
133133
renderControl={({title, triggerProps, ref}) => {
134134
return (
135-
<Button ref={ref} {...triggerProps}>
135+
<Button ref={ref} {...triggerProps} extraProps={triggerProps}>
136136
{title || 'Not selected'}
137137
</Button>
138138
);

src/components/RelativeRangeDatePicker/components/Control/Control.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {getDefaultTitle} from '../../utils';
1111

1212
import {i18n} from './i18n';
1313

14+
import './Control.scss';
15+
1416
export type ControlProps = {
1517
props: RelativeRangeDatePickerProps;
1618
state: RelativeRangeDatePickerState;
@@ -51,13 +53,17 @@ export const Control = React.forwardRef<HTMLInputElement, ControlProps>(
5153
const errorMessage = props.errorMessage ?? state.errors.join('\n');
5254

5355
const triggerProps: RelativeRangeDatePickerTriggerProps = {
56+
id: props.id,
5457
role: 'combobox',
5558
'aria-expanded': open,
59+
'aria-label': props['aria-label'],
60+
'aria-labelledby': props['aria-labelledby'],
61+
'aria-describedby': props['aria-describedby'],
62+
'aria-details': props['aria-details'],
5663
disabled: props.disabled,
5764
readOnly: props.readOnly,
58-
onClick,
65+
onClick: onClickCalendar,
5966
onKeyDown,
60-
onFocus,
6167
};
6268

6369
return props.renderControl ? (
@@ -68,7 +74,6 @@ export const Control = React.forwardRef<HTMLInputElement, ControlProps>(
6874
validationState,
6975
errorMessage,
7076
open,
71-
isMobile,
7277
triggerProps,
7378
})
7479
) : (
@@ -84,6 +89,7 @@ export const Control = React.forwardRef<HTMLInputElement, ControlProps>(
8489
className: b('input', {mobile: isMobile}),
8590
...triggerProps,
8691
disabled: isMobile,
92+
onClick,
8793
}}
8894
onKeyDown={onKeyDown}
8995
onFocus={onFocus}

src/components/RelativeRangeDatePicker/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {DateTime} from '@gravity-ui/date-utils';
22

33
import type {Value} from '../RelativeDatePicker';
44
import type {
5+
AccessibilityProps,
56
DomProps,
67
FocusableProps,
78
InputBase,
@@ -32,7 +33,6 @@ export type RelativeRangeDatePickerTriggerProps = Pick<
3233
| 'aria-details'
3334
| 'onClick'
3435
| 'onKeyDown'
35-
| 'onFocus'
3636
| 'disabled'
3737
| 'readOnly'
3838
>;
@@ -44,13 +44,13 @@ export interface RelativeRangeDatePickerRenderControlProps {
4444
errorMessage?: React.ReactNode;
4545
validationState?: 'invalid';
4646
open: boolean;
47-
isMobile?: boolean;
4847
triggerProps: RelativeRangeDatePickerTriggerProps;
4948
}
5049

5150
export interface RelativeRangeDatePickerProps
5251
extends RelativeRangeDatePickerStateOptions,
5352
DomProps,
53+
AccessibilityProps,
5454
InputBase,
5555
InputDOMProps,
5656
TextInputProps,

0 commit comments

Comments
 (0)