Skip to content

Commit e0928f6

Browse files
committed
refactor(ui): data-esc-closable is true when allow esc to close and visible
1 parent 6f06fda commit e0928f6

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

packages/ui/src/components/_date-input/DateInput.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { checkNodeExist, getClassName, getVerticalSidePosition } from '@react-de
1212
import { dayjs } from '../../dayjs';
1313
import { useDValue, useMaxIndex } from '../../hooks';
1414
import { cloneHTMLElement, TTANSITION_DURING_POPUP, WINDOW_SPACE } from '../../utils';
15-
import { EXPANDED_DATA } from '../../utils/checkNoExpandedEl';
15+
import { ESC_CLOSABLE_DATA } from '../../utils/checkNoExpandedEl';
1616
import { DBaseDesign } from '../_base-design';
1717
import { DBaseInput } from '../_base-input';
1818
import { DComboboxKeyboard } from '../_keyboard';
@@ -378,7 +378,7 @@ function DateInput(props: DDateInputProps, ref: React.ForwardedRef<DDateInputRef
378378
renderBaseDesign(
379379
<div
380380
{...restProps}
381-
{...{ [EXPANDED_DATA]: visible }}
381+
{...{ [ESC_CLOSABLE_DATA]: visible }}
382382
ref={boxRef}
383383
className={getClassName(restProps.className, prefix, {
384384
[`${prefix}--${dSize}`]: dSize,

packages/ui/src/components/_selectbox/Selectbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { checkNodeExist, getClassName } from '@react-devui/utils';
1111

1212
import { useMaxIndex } from '../../hooks';
1313
import { cloneHTMLElement } from '../../utils';
14-
import { EXPANDED_DATA } from '../../utils/checkNoExpandedEl';
14+
import { ESC_CLOSABLE_DATA } from '../../utils/checkNoExpandedEl';
1515
import { DBaseDesign } from '../_base-design';
1616
import { DBaseInput } from '../_base-input';
1717
import { DFocusVisible } from '../_focus-visible';
@@ -144,7 +144,7 @@ export function DSelectbox(props: DSelectboxProps): JSX.Element | null {
144144
renderBaseDesign(
145145
<div
146146
{...restProps}
147-
{...{ [EXPANDED_DATA]: dVisible }}
147+
{...{ [ESC_CLOSABLE_DATA]: dVisible }}
148148
ref={combineBoxRef}
149149
className={getClassName(restProps.className, prefix, {
150150
[`${prefix}--${dSize}`]: dSize,

packages/ui/src/components/dropdown/Dropdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getClassName, getVerticalSidePosition, scrollToView } from '@react-devu
99

1010
import { useMaxIndex, useDValue } from '../../hooks';
1111
import { registerComponentMate, TTANSITION_DURING_POPUP, WINDOW_SPACE } from '../../utils';
12-
import { EXPANDED_DATA } from '../../utils/checkNoExpandedEl';
12+
import { ESC_CLOSABLE_DATA } from '../../utils/checkNoExpandedEl';
1313
import { DFocusVisible } from '../_focus-visible';
1414
import { DPopup, useNestedPopup } from '../_popup';
1515
import { DTransition } from '../_transition';
@@ -445,7 +445,7 @@ function Dropdown<ID extends DId, T extends DDropdownItem<ID>>(
445445
'aria-haspopup': 'menu',
446446
'aria-expanded': visible,
447447
'aria-controls': id,
448-
[EXPANDED_DATA as string]: visible,
448+
[ESC_CLOSABLE_DATA as string]: visible,
449449
onFocus: (e) => {
450450
children.props.onFocus?.(e);
451451

packages/ui/src/components/menu/Menu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { findNested, getClassName } from '@react-devui/utils';
88

99
import { useDValue } from '../../hooks';
1010
import { registerComponentMate, TTANSITION_DURING_BASE } from '../../utils';
11-
import { EXPANDED_DATA } from '../../utils/checkNoExpandedEl';
11+
import { ESC_CLOSABLE_DATA } from '../../utils/checkNoExpandedEl';
1212
import { DFocusVisible } from '../_focus-visible';
1313
import { useNestedPopup } from '../_popup';
1414
import { DCollapseTransition } from '../_transition';
@@ -504,7 +504,7 @@ function Menu<ID extends DId, T extends DMenuItem<ID>>(props: DMenuProps<ID, T>,
504504
// eslint-disable-next-line jsx-a11y/aria-activedescendant-has-tabindex
505505
<nav
506506
{...restProps}
507-
{...{ [EXPANDED_DATA]: popupIds.length > 0 }}
507+
{...{ [ESC_CLOSABLE_DATA]: popupIds.length > 0 }}
508508
ref={collapseRef}
509509
className={getClassName(restProps.className, `${dPrefix}menu`, {
510510
[`${dPrefix}menu--horizontal`]: dMode === 'horizontal',

packages/ui/src/components/popover/Popover.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { getClassName, getPopupPosition } from '@react-devui/utils';
1212

1313
import { useMaxIndex, useDValue } from '../../hooks';
1414
import { registerComponentMate, handleModalKeyDown, cloneHTMLElement, checkNoExpandedEl } from '../../utils';
15-
import { EXPANDED_DATA } from '../../utils/checkNoExpandedEl';
15+
import { ESC_CLOSABLE_DATA } from '../../utils/checkNoExpandedEl';
1616
import { DPopup } from '../_popup';
1717
import { DTransition } from '../_transition';
1818
import { useComponentConfig, usePrefixConfig } from '../root';
@@ -299,7 +299,7 @@ function Popover(props: DPopoverProps, ref: React.ForwardedRef<DPopoverRef>): JS
299299
{renderTrigger(
300300
cloneHTMLElement(children, {
301301
id: triggerId,
302-
[EXPANDED_DATA]: visible,
302+
[ESC_CLOSABLE_DATA]: dEscClosable && visible,
303303
})
304304
)}
305305
{containerRef.current &&

packages/ui/src/components/tooltip/Tooltip.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { getClassName, getPopupPosition } from '@react-devui/utils';
1010

1111
import { useMaxIndex, useDValue } from '../../hooks';
1212
import { checkNoExpandedEl, registerComponentMate } from '../../utils';
13-
import { EXPANDED_DATA } from '../../utils/checkNoExpandedEl';
13+
import { ESC_CLOSABLE_DATA } from '../../utils/checkNoExpandedEl';
1414
import { DPopup } from '../_popup';
1515
import { DTransition } from '../_transition';
1616
import { useComponentConfig, usePrefixConfig } from '../root';
@@ -251,7 +251,7 @@ function Tooltip(props: DTooltipProps, ref: React.ForwardedRef<DTooltipRef>): JS
251251
{renderTrigger(
252252
React.cloneElement(children, {
253253
'aria-describedby': id,
254-
[EXPANDED_DATA]: visible,
254+
[ESC_CLOSABLE_DATA]: dEscClosable && visible,
255255
})
256256
)}
257257
{containerRef.current &&
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { isNull } from 'lodash';
22

3-
export const EXPANDED_DATA = 'data-popup-expanded';
3+
export const ESC_CLOSABLE_DATA = 'data-esc-closable';
44
export function checkNoExpandedEl(el: HTMLElement) {
5-
return isNull(el.querySelector(`[${EXPANDED_DATA}="true"]`));
5+
return isNull(el.querySelector(`[${ESC_CLOSABLE_DATA}="true"]`));
66
}

0 commit comments

Comments
 (0)