WPML
สถานะ
เปิด
รายงานสำหรับ
WPML Multilingual CMS 4.6.11
แท็กหัวข้อ
Bug

ภาพรวมของปัญหา

หากคุณกำลังใช้ บล็อกตัวสลับภาษาของ Gutenberg และตัวเลือก Dropdown click คุณจะสังเกตเห็นว่าเมื่อคลิกภายนอกพื้นที่เมนูแบบเลื่อนลง เมนูจะไม่ปิดตามที่คาดไว้

วิธีแก้ปัญหาชั่วคราว

โปรดตรวจสอบให้แน่ใจว่าคุณได้สำรองข้อมูลไซต์อย่างสมบูรณ์สำหรับไซต์ของคุณก่อนดำเนินการต่อ


  • เปิดไฟล์ …/wp-content/plugins/sitepress-multilingual-cms/classes/block-editor/Blocks/LanguageSwitcher/Render.php

  • ค้นหาบรรทัดที่ 123

  • แทนที่:
    				if ( $dpFirstItem ) {
    					$dpFirstItem->setAttribute(
    						'onclick',
    						"(()=>{const ariaExpanded = this.children[0].getAttribute('aria-expanded');
    					this.children[0].setAttribute('aria-expanded', ariaExpanded === 'true' ? 'false' : 'true');})(this);"
    					);
    				}

  • ด้วย:
    if ($dpFirstItem) {
        $dpFirstItem->setAttribute(
            'onclick',
            "(()=>{
                const ariaExpanded = this.children[0].getAttribute('aria-expanded');
                this.children[0].setAttribute('aria-expanded', ariaExpanded === 'true' ? 'false' : 'true');
                
                if (ariaExpanded !== 'true') {
                    const expandedItem = this;
                    const closeExpandedItem = (event) => {
                        if (!expandedItem.contains(event.target)) {
                            expandedItem.children[0].setAttribute('aria-expanded', 'false');
                            document.removeEventListener('click', closeExpandedItem);
                        }
                    };
                    document.addEventListener('click', closeExpandedItem);
                }
            })(this);"
        );
    }

ปัญหาที่ทราบแล้วทั้งหมด →