welcome-notice.js: the dismiss callback is sent as POST data, and `attr( 'disabled', true )` warns on WordPress 7.2

Đang mở Phù hợp với người mới
#122 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
92/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, jquery
Lĩnh vực
frontend

Hướng nghiên cứu

Mở assets/js/src/welcome-notice.js: yêu cầu đóng được xây dựng quanh dòng 61–65, và nút cài đặt bị vô hiệu hóa quanh dòng 48. Di chuyển success: hideAndRemoveNotice ra khỏi đối tượng dữ liệu của $.post và gắn nó bằng .done( hideAndRemoveNotice ), sau đó chuyển installBtn.attr( 'disabled', true ) thành .prop( 'disabled', true ). Để xác minh, tải thông báo chào mừng với SCRIPT_DEBUG bật và đóng nó, kiểm tra rằng thông báo chỉ biến mất sau khi yêu cầu thành công và jQuery Migrate không còn cảnh báo khi nhấp vào Install & Activate Otter Blocks.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

What's wrong

Two small problems in assets/js/src/welcome-notice.js. Neither breaks the notice today.

  1. Dismiss. Lines 61–65:

    $.post( ajaxUrl, {
    	nonce,
    	action: 'fork_dismiss_welcome_notice',
    	success: hideAndRemoveNotice,
    } );
    

    success is inside the data object, not passed as a callback. When jQuery serializes data it calls any function it finds, so hideAndRemoveNotice() runs immediately when the request is built, and the request carries an empty success= field. As a result, the notice disappears even if the dismissal is not saved (for example after an expired nonce), and then comes back on the next page load. Found by reading the code.

  2. Disabled button. Line 48, installBtn.attr( 'disabled', true );. With SCRIPT_DEBUG on, WordPress 7.2's jQuery Migrate 3.6 logs JQMIGRATE: Boolean attribute 'disabled' is not set to its lowercased name when Install & Activate Otter Blocks is clicked. Seen on 7.2-RC2; the install still completes. WordPress plans to move to jQuery 4 in 7.3.

Suggested fix
$.post( ajaxUrl, { nonce, action: 'fork_dismiss_welcome_notice' } ).done( hideAndRemoveNotice );

and installBtn.prop( 'disabled', true );.

Ngôn ngữ chính
PHP
Star
0
Fork
0
Merge trung bình
1 giờ 2 phút
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Codeinwp/fork

Tất cả issue của Codeinwp/fork

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.