소스 검색

fix(select): aria-controls value bug in ssr #840 (#845)

Co-authored-by: shijia.me <[email protected]>
走鹃 3 년 전
부모
커밋
6acf4fa4ed
1개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      packages/semi-ui/select/index.tsx

+ 3 - 1
packages/semi-ui/select/index.tsx

@@ -28,6 +28,7 @@ import { isSemiIcon } from '../_utils';
 import { Subtract } from 'utility-types';
 import { Subtract } from 'utility-types';
 
 
 import warning from '@douyinfe/semi-foundation/utils/warning';
 import warning from '@douyinfe/semi-foundation/utils/warning';
+import { getUuidShort } from '@douyinfe/semi-foundation/utils/uuid';
 
 
 import '@douyinfe/semi-foundation/select/select.scss';
 import '@douyinfe/semi-foundation/select/select.scss';
 import { Locale } from '../locale/interface';
 import { Locale } from '../locale/interface';
@@ -340,7 +341,7 @@ class Select extends BaseComponent<SelectProps, SelectState> {
             isHovering: false,
             isHovering: false,
         };
         };
         /* Generate random string */
         /* Generate random string */
-        this.selectOptionListID = Math.random().toString(36).slice(2);
+        this.selectOptionListID = '';
         this.virtualizeListRef = React.createRef();
         this.virtualizeListRef = React.createRef();
         this.inputRef = React.createRef();
         this.inputRef = React.createRef();
         this.triggerRef = React.createRef();
         this.triggerRef = React.createRef();
@@ -559,6 +560,7 @@ class Select extends BaseComponent<SelectProps, SelectState> {
 
 
     componentDidMount() {
     componentDidMount() {
         this.foundation.init();
         this.foundation.init();
+        this.selectOptionListID = getUuidShort();
     }
     }
 
 
     componentWillUnmount() {
     componentWillUnmount() {