FSE Design Pack editor notice never shows on WordPress 6.8+ (core renamed the pattern-inserted notice id)

オープン 初心者向け
#132 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, wordpress
領域
frontend

調査の方向性

assets/js/src/components/DesignPackNotice.jsから始めて、Coreエディターの通知をどのように読み取り、パターン挿入時に表示されるスナックバーをどのように識別しているかを確認してください。WordPressの各バージョンで使われる通知IDに対応しつつ、他のインサーター通知ではアップセルが表示されないようにしてください。WordPress 6.7および6.8+でパターンを挿入した後に通知が表示され、画像を挿入した後には表示されないことを確認してください。

索引モデルが issue の本文から書いたものです。

説明

What's wrong

After you insert a pattern in the editor, Riverbank is supposed to show its "FSE Design Pack" upsell notice. Since WordPress 6.8 that notice never shows. Nothing errors and nothing is logged. It just doesn't appear.

The cause: assets/js/src/components/DesignPackNotice.js waits for a core notice with the id block-pattern-inserted-notice:

const BLOCK_PATTERN_INSERTED_NOTICE = 'block-pattern-inserted-notice';
// ...
.getNotices().filter( ( n ) => n.id === BLOCK_PATTERN_INSERTED_NOTICE ).length > 0

Core's block editor used that id from WordPress 6.3 to 6.7. From 6.8 onwards it uses inserter-notice for the same pattern-inserted snackbar (checked in the 6.8.1, 7.0.7 and 7.1.5 builds of wp-includes/js/dist/block-editor.js). So the theme waits for a notice that never comes.

Steps to reproduce

The quickest way to see it is side by side: one Playground where the notice works, one where it doesn't. Both sites are fresh, so the FSE Design Pack plugin isn't installed and the notice has never been dismissed.

In each one:

  1. Wait for the page editor to load. Collapse Playground's dark toolbar at the bottom (the ⌄ arrow next to "Autosaved"). The notice appears in the bottom-right corner, and the toolbar covers most of it.
  2. Click the blue + (Block Inserter) at the top left, open the Patterns tab, then pick a pattern category (the theme's own category, or any other).
  3. Click a pattern to insert it. Click it rather than dragging it onto the canvas: the theme only reacts to core's "pattern inserted" snackbar, and these steps were checked with a click.

On an existing site: the notice is skipped if the FSE Design Pack plugin is active, or once it has been dismissed. Dismissing it sets the option riverbank-design-pack-dismissed to yes. Delete that option, or use a fresh site.

Expected (what you see on 6.7)

About half a second after you insert the pattern, a white card slides in at the bottom right: the theme logo, "Riverbank recommends", "FSE Design Pack: Access a collection of 40+ layout patterns ready to import to your website", a blue Learn More button and an ×. Core's black "Block pattern "…" inserted." snackbar shows at the bottom left at the same time.

Actual (WordPress 6.8 and newer)

Core's snackbar shows (on 6.8+ it reads "Pattern "…" inserted."), but the card never appears. Nothing shows in the console, and the notice container (#riverbank-design-pack-notice) stays empty. The theme does load its script: window.designPackNoticeData is defined.

Found with Jaxon 1.0.13 on WordPress 7.1.5 (wp-env) and checked in Playground on 6.7 against the latest WordPress. Riverbank 1.0.18 has the same DesignPackNotice.js code on its default branch.

Suggested fix

Accept both ids, so it keeps working on 6.3 to 6.7 as well:

const PATTERN_NOTICE_IDS = [ 'block-pattern-inserted-notice', 'inserter-notice' ];
// ...
.filter( ( n ) => PATTERN_NOTICE_IDS.includes( n.id ) )

⚠️ Caveat: on 6.8+, core also uses inserter-notice for other inserter snackbars, such as "Image inserted.", "Image uploaded and inserted.", "Block "%s" can't be inserted." and the gallery attach/detach messages. Matching the id alone would also show the upsell after inserting an image. If the notice should only follow a pattern insertion, also check the text when the id is inserter-notice. For example, build a matcher from the same translated string core uses (__( 'Pattern "%s" inserted.' ) resolves through the shared default text domain):

const [ before, after ] = __( 'Pattern "%s" inserted.' ).split( '%s' );
const isPatternNotice = ( n ) =>
	n.id === 'block-pattern-inserted-notice' ||
	( n.id === 'inserter-notice' &&
		typeof n.content === 'string' &&
		n.content.startsWith( before ) &&
		n.content.endsWith( after ) );
Same bug in the other FSE themes
  • Codeinwp/neve-fse#214
  • Codeinwp/raft#203
  • Codeinwp/jaxon#119
  • Codeinwp/fork#117
主要言語
PHP
スター
2
フォーク
0
平均マージ
4時間 59分
マージ済み PR(30日)
5

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Codeinwp/riverbank のほかの issue

Codeinwp/riverbank の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。