Преглед изворни кода

fix: checkout ally click focus-visible

zhangyumei.0319 пре 3 година
родитељ
комит
fb89e30da3
1 измењених фајлова са 10 додато и 0 уклоњено
  1. 10 0
      packages/semi-foundation/checkbox/checkboxFoundation.ts

+ 10 - 0
packages/semi-foundation/checkbox/checkboxFoundation.ts

@@ -33,6 +33,8 @@ class CheckboxFoundation<P = Record<string, any>, S = Record<string, any>> exten
         super({ ...adapter });
     }
 
+    clickState = false;
+
     init() {
         const { children, extra, extraId, addonId } = this.getProps();
         if (children && !addonId) {
@@ -79,6 +81,10 @@ class CheckboxFoundation<P = Record<string, any>, S = Record<string, any>> exten
             return;
         }
 
+        if (e?.type === 'click') {
+            this.clickState = true;
+        }
+
         this._adapter.focusCheckboxEntity();
 
         const isInGroup = this._adapter.getIsInGroup();
@@ -125,6 +131,10 @@ class CheckboxFoundation<P = Record<string, any>, S = Record<string, any>> exten
     handleFocusVisible = (event: any) => {
         const { target } = event;
         try {
+            if( this.clickState ) {
+                this.clickState = false;
+                return;
+            } 
             if (target.matches(':focus-visible')) {
                 this._adapter.setFocusVisible(true);
             }