@tarojs/components-react 4.1.12-beta.61 → 4.1.12-beta.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,16 @@ function usePickerItemScrollIntoView() {
18
18
  }, []);
19
19
  return [scrollIntoView, scrollToItemId];
20
20
  }
21
+ /** 系统读屏是否开启:开启时 mask 需可命中(关掉 pointer-events:none) */
22
+ function useA11yOpen() {
23
+ const [a11yOpen, setA11yOpen] = React.useState(false);
24
+ React.useEffect(() => {
25
+ Taro.checkIsOpenAccessibility().then(res => {
26
+ setA11yOpen(!!res.open);
27
+ }).catch(() => {});
28
+ }, []);
29
+ return a11yOpen;
30
+ }
21
31
  // 定义常量
22
32
  const PICKER_LINE_HEIGHT = 34; // px
23
33
  const PICKER_VISIBLE_ITEMS = 7; // 可见行数
@@ -128,6 +138,8 @@ function PickerGroupBasic(props) {
128
138
  const [currentIndex, setCurrentIndex] = React.useState(selectedIndex);
129
139
  // 触摸状态用于优化用户体验
130
140
  const isTouchingRef = React.useRef(false);
141
+ // 系统读屏开启时关闭 mask 的 pointer-events:none,便于无障碍命中;未开启则保持穿透以便手势滚动
142
+ const a11yOpen = useA11yOpen();
131
143
  const lengthScaleRatioRef = React.useRef(1);
132
144
  const useMeasuredScaleRef = React.useRef(false);
133
145
  const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
@@ -288,10 +300,21 @@ function PickerGroupBasic(props) {
288
300
  get children() {
289
301
  return [createComponent(View, {
290
302
  className: "taro-picker__mask",
291
- ariaHidden: true
303
+ style: a11yOpen ? {
304
+ pointerEvents: 'auto'
305
+ } : undefined,
306
+ ariaRole: "slider",
307
+ ariaLabel: ariaLabel,
308
+ ariaAction: [{
309
+ name: 'increment',
310
+ label: 'increment'
311
+ }, {
312
+ name: 'decrement',
313
+ label: 'decrement'
314
+ }],
315
+ onAriaAction: handleAriaAction
292
316
  }), createComponent(View, mergeProps({
293
- className: "taro-picker__indicator",
294
- ariaHidden: true
317
+ className: "taro-picker__indicator"
295
318
  }, indicatorStyle ? {
296
319
  style: indicatorStyle
297
320
  } : {})), createComponent(ScrollView, mergeProps({
@@ -299,11 +322,7 @@ function PickerGroupBasic(props) {
299
322
  scrollY: true,
300
323
  showScrollbar: false,
301
324
  className: "taro-picker__content",
302
- ariaHidden: true
303
- }, {
304
- accessibilityElementsHidden: true,
305
- importantForAccessibility: 'no-hide-descendants'
306
- }, {
325
+ ariaHidden: true,
307
326
  style: {
308
327
  height: PICKER_LINE_HEIGHT * PICKER_VISIBLE_ITEMS
309
328
  },
@@ -316,28 +335,6 @@ function PickerGroupBasic(props) {
316
335
  onScrollEnd: handleScrollEnd,
317
336
  scrollWithAnimation: true,
318
337
  children: realPickerItems
319
- })), createComponent(View, mergeProps({
320
- className: "taro-picker__a11y-overlay",
321
- style: {
322
- position: 'absolute',
323
- top: 0,
324
- left: 0,
325
- right: 0,
326
- bottom: 0,
327
- pointerEvents: 'none'
328
- },
329
- ariaRole: "slider"
330
- }, ariaLabel !== undefined ? {
331
- ariaLabel
332
- } : {}, {
333
- ariaAction: [{
334
- name: 'increment',
335
- label: 'increment'
336
- }, {
337
- name: 'decrement',
338
- label: 'decrement'
339
- }],
340
- onAriaAction: handleAriaAction
341
338
  }))];
342
339
  }
343
340
  });
@@ -361,6 +358,7 @@ function PickerGroupTime(props) {
361
358
  const scrollViewRef = React.useRef(null);
362
359
  const [currentIndex, setCurrentIndex] = React.useState(selectedIndex);
363
360
  const isTouchingRef = React.useRef(false);
361
+ const a11yOpen = useA11yOpen();
364
362
  const lengthScaleRatioRef = React.useRef(1);
365
363
  const useMeasuredScaleRef = React.useRef(false);
366
364
  const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
@@ -537,7 +535,19 @@ function PickerGroupTime(props) {
537
535
  get children() {
538
536
  return [createComponent(View, {
539
537
  className: "taro-picker__mask",
540
- ariaHidden: true
538
+ style: a11yOpen ? {
539
+ pointerEvents: 'auto'
540
+ } : undefined,
541
+ ariaRole: "slider",
542
+ ariaLabel: ariaLabel,
543
+ ariaAction: [{
544
+ name: 'increment',
545
+ label: 'increment'
546
+ }, {
547
+ name: 'decrement',
548
+ label: 'decrement'
549
+ }],
550
+ onAriaAction: handleAriaAction
541
551
  }), createComponent(View, mergeProps({
542
552
  className: "taro-picker__indicator",
543
553
  ariaHidden: true
@@ -565,28 +575,6 @@ function PickerGroupTime(props) {
565
575
  onScrollEnd: handleScrollEnd,
566
576
  scrollWithAnimation: true,
567
577
  children: realPickerItems
568
- })), createComponent(View, mergeProps({
569
- className: "taro-picker__a11y-overlay",
570
- style: {
571
- position: 'absolute',
572
- top: 0,
573
- left: 0,
574
- right: 0,
575
- bottom: 0,
576
- pointerEvents: 'none'
577
- },
578
- ariaRole: "slider"
579
- }, ariaLabel !== undefined ? {
580
- ariaLabel
581
- } : {}, {
582
- ariaAction: [{
583
- name: 'increment',
584
- label: 'increment'
585
- }, {
586
- name: 'decrement',
587
- label: 'decrement'
588
- }],
589
- onAriaAction: handleAriaAction
590
578
  }))];
591
579
  }
592
580
  });
@@ -607,6 +595,7 @@ function PickerGroupDate(props) {
607
595
  const scrollViewRef = React.useRef(null);
608
596
  const [currentIndex, setCurrentIndex] = React.useState(selectedIndex);
609
597
  const isTouchingRef = React.useRef(false);
598
+ const a11yOpen = useA11yOpen();
610
599
  const lengthScaleRatioRef = React.useRef(1);
611
600
  const useMeasuredScaleRef = React.useRef(false);
612
601
  const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
@@ -762,7 +751,19 @@ function PickerGroupDate(props) {
762
751
  get children() {
763
752
  return [createComponent(View, {
764
753
  className: "taro-picker__mask",
765
- ariaHidden: true
754
+ style: a11yOpen ? {
755
+ pointerEvents: 'auto'
756
+ } : undefined,
757
+ ariaRole: "slider",
758
+ ariaLabel: ariaLabel,
759
+ ariaAction: [{
760
+ name: 'increment',
761
+ label: 'increment'
762
+ }, {
763
+ name: 'decrement',
764
+ label: 'decrement'
765
+ }],
766
+ onAriaAction: handleAriaAction
766
767
  }), createComponent(View, mergeProps({
767
768
  className: "taro-picker__indicator",
768
769
  ariaHidden: true
@@ -790,28 +791,6 @@ function PickerGroupDate(props) {
790
791
  onScrollEnd: handleScrollEnd,
791
792
  scrollWithAnimation: true,
792
793
  children: realPickerItems
793
- })), createComponent(View, mergeProps({
794
- className: "taro-picker__a11y-overlay",
795
- style: {
796
- position: 'absolute',
797
- top: 0,
798
- left: 0,
799
- right: 0,
800
- bottom: 0,
801
- pointerEvents: 'none'
802
- },
803
- ariaRole: "slider"
804
- }, ariaLabel !== undefined ? {
805
- ariaLabel
806
- } : {}, {
807
- ariaAction: [{
808
- name: 'increment',
809
- label: 'increment'
810
- }, {
811
- name: 'decrement',
812
- label: 'decrement'
813
- }],
814
- onAriaAction: handleAriaAction
815
794
  }))];
816
795
  }
817
796
  });
@@ -836,6 +815,7 @@ function PickerGroupRegion(props) {
836
815
  const isTouchingRef = React.useRef(false);
837
816
  // 程序化滚动标记:开屏/受控同步预设值时置 true,避免被 region 级联门误判为用户滚动而重置后续列
838
817
  const syncScrollFromPropsRef = React.useRef(false);
818
+ const a11yOpen = useA11yOpen();
839
819
  const lengthScaleRatioRef = React.useRef(1);
840
820
  const useMeasuredScaleRef = React.useRef(false);
841
821
  const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
@@ -999,7 +979,19 @@ function PickerGroupRegion(props) {
999
979
  get children() {
1000
980
  return [createComponent(View, {
1001
981
  className: "taro-picker__mask",
1002
- ariaHidden: true
982
+ style: a11yOpen ? {
983
+ pointerEvents: 'auto'
984
+ } : undefined,
985
+ ariaRole: "slider",
986
+ ariaLabel: ariaLabel,
987
+ ariaAction: [{
988
+ name: 'increment',
989
+ label: 'increment'
990
+ }, {
991
+ name: 'decrement',
992
+ label: 'decrement'
993
+ }],
994
+ onAriaAction: handleAriaAction
1003
995
  }), createComponent(View, mergeProps({
1004
996
  className: "taro-picker__indicator",
1005
997
  ariaHidden: true
@@ -1027,28 +1019,6 @@ function PickerGroupRegion(props) {
1027
1019
  onScrollEnd: handleScrollEnd,
1028
1020
  scrollWithAnimation: true,
1029
1021
  children: realPickerItems
1030
- })), createComponent(View, mergeProps({
1031
- className: "taro-picker__a11y-overlay",
1032
- style: {
1033
- position: 'absolute',
1034
- top: 0,
1035
- left: 0,
1036
- right: 0,
1037
- bottom: 0,
1038
- pointerEvents: 'none'
1039
- },
1040
- ariaRole: "slider"
1041
- }, ariaLabel !== undefined ? {
1042
- ariaLabel
1043
- } : {}, {
1044
- ariaAction: [{
1045
- name: 'increment',
1046
- label: 'increment'
1047
- }, {
1048
- name: 'decrement',
1049
- label: 'decrement'
1050
- }],
1051
- onAriaAction: handleAriaAction
1052
1022
  }))];
1053
1023
  }
1054
1024
  });