ux: make the "No notes found" empty-state notice dismissible
The inline notice on the My Notes page rendered with class="notice notice-info" but no is-dismissible modifier, so WordPress's core common.js never attached an X close button. Users had no way to clear the empty-state message for the current view. Audited every notice the plugin emits while I was in there — the migration notice and the settings_errors() calls were already correctly dismissible AND only fired in their intended state. The empty-state notice was the only laggard. All four notice paths now share the same contract: dismissible by the user, AND only rendered when the underlying state warrants it. Dismissal is per-page-load (WP core's default behavior — clicking X hides the element for the current view only). Cross-page-load persistence would need user_meta or a transient and isn't built yet; flagged in the changelog for a future enhancement. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,26 @@ Format: [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/) — versi
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed — Empty-state notice ("No notes found") now dismissible
|
||||||
|
The "No active notes found" / "No completed notes found" inline
|
||||||
|
notice on the My Notes page rendered with `class="notice notice-info"`
|
||||||
|
but no `is-dismissible` modifier, so WordPress's core common.js
|
||||||
|
never attached an X close button to it. Users couldn't clear the
|
||||||
|
message for the current view. Adding `is-dismissible` is the only
|
||||||
|
change — WP core handles the X button render + click-to-hide
|
||||||
|
automatically. Dismissal is per-page-load (the message reappears on
|
||||||
|
next refresh if the list is still empty); persistence across
|
||||||
|
reloads would need user_meta tracking and isn't built yet.
|
||||||
|
|
||||||
|
**Notice inventory after this fix** — every notice the plugin emits
|
||||||
|
is now both dismissible AND only fires in its intended state:
|
||||||
|
|
||||||
|
| Notice | Class | Fires when |
|
||||||
|
|---|---|---|
|
||||||
|
| "No active/completed notes found" | `notice notice-info is-dismissible` | List is empty |
|
||||||
|
| Migration prompt | `notice notice-info is-dismissible` | `wp_notes_migration_completed` option is unset |
|
||||||
|
| Settings save / import errors / import success | rendered by core `settings_errors()` (auto-dismissible since WP 4.2) | Only on form submission events |
|
||||||
|
|
||||||
### Changed — Removed duplicate smiley-face button on the emoji picker
|
### Changed — Removed duplicate smiley-face button on the emoji picker
|
||||||
The "Add emoji" formatting option rendered two clickable elements
|
The "Add emoji" formatting option rendered two clickable elements
|
||||||
stacked: the *"Click to add emoji"* text input AND a separate button
|
stacked: the *"Click to add emoji"* text input AND a separate button
|
||||||
|
|||||||
@@ -22,7 +22,12 @@ function wp_notes_display_notes($type = 'active') {
|
|||||||
$section_title = ($type === 'active') ? 'Active Notes' : 'Completed Notes';
|
$section_title = ($type === 'active') ? 'Active Notes' : 'Completed Notes';
|
||||||
|
|
||||||
if (empty($notes)) {
|
if (empty($notes)) {
|
||||||
echo '<div class="wp-notes-empty notice notice-info">';
|
/* is-dismissible adds an X button via WP core's common.js so
|
||||||
|
users can clear the empty-state message for the current view.
|
||||||
|
Dismissal is per-page-load (the message reappears on next
|
||||||
|
refresh if the list is still empty) — persistence across
|
||||||
|
reloads would need user_meta tracking and isn't built yet. */
|
||||||
|
echo '<div class="wp-notes-empty notice notice-info is-dismissible">';
|
||||||
echo '<p>' . esc_html__('No ' . ($type === 'active' ? 'active' : 'completed') . ' notes found.', 'a-wp-notes') . '</p>';
|
echo '<p>' . esc_html__('No ' . ($type === 'active' ? 'active' : 'completed') . ' notes found.', 'a-wp-notes') . '</p>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user