Skip to content

fix: hide search + hide notification toggles their elements for v16#23

Open
sparsh-dhris wants to merge 3 commits into
dhwani-ris:developmentfrom
sparsh-dhris:fix/hide-search-notification
Open

fix: hide search + hide notification toggles their elements for v16#23
sparsh-dhris wants to merge 3 commits into
dhwani-ris:developmentfrom
sparsh-dhris:fix/hide-search-notification

Conversation

@sparsh-dhris

Copy link
Copy Markdown

Problem

Two Desk Theme settings don't work on Frappe v16:

  • Hide Notification (hide_notification) — toggling has no effect.
  • Hide Search (hide_search, role-based) — toggling has no effect.

Root cause

In frappe_desk_theme.bundle.js:

  1. toggleSearchBar() queries .input-group.search-bar.text-muted — the v15 navbar selector. In v16 the search moved to the sidebar (.body-sidebar .navbar-search-bar), so the lookup returns null and the function silently no-ops. It also only hides, never restores.
  2. hide_notification is defined in desk_theme.json and served by the API, but no JS code reads it. Zero consumers.

Fix

JS-only, no schema or API change.

  • toggleSearchBar() now matches both the v15 and v16 selectors and restores display: "" when the role no longer matches (reversible).
  • New toggleNotification() reads hide_notification and toggles .body-sidebar .sidebar-notification (v16) / .navbar-nav .dropdown-notifications (v15).
  • Both wired into applyTheme() and the existing MutationObserver in setupEventListeners() so they survive sidebar re-renders.

Tests

Added to test_desk_theme.py:

Test Type Always runs?
test_doctype_exposes_hide_notification_and_hide_search_fields Schema contract yes
test_api_round_trips_both_fields Data layer roundtrip yes
test_hide_notification_flag_actually_hides_sidebar_bell Playwright E2E opt-in via DESK_THEME_E2E_SITE
test_hide_search_for_role_actually_hides_sidebar_search Playwright E2E opt-in via DESK_THEME_E2E_SITE

Schema/API tests use unittest.TestCase to bypass Frappe's transitive fixture loader (which can fail on sites with customised ToDo / Email Account doctypes).

Local verification

5 scenarios run against a live v16 site — all pass, including the all-off-after-all-on case that proves reversibility.

Risk

JS-only, backwards-compatible with v15, rollback = git revert. Cached themes pick up the fix on next API revalidation.

- toggleSearchBar() now matches both the v15 navbar selector and the v16
  sidebar selector (.body-sidebar .navbar-search-bar), and restores the
  element's display when the role no longer matches.
- New toggleNotification() reads the previously-orphaned hide_notification
  field and toggles .sidebar-notification (v16) / .dropdown-notifications
  (v15).
- Both wired into applyTheme() and the existing MutationObserver so they
  survive sidebar re-renders.
- Added schema + data-layer unit tests and opt-in Playwright E2E tests
  (gated by DESK_THEME_E2E_SITE env var to keep standard CI fast).
@sparsh-dhris sparsh-dhris force-pushed the fix/hide-search-notification branch from 24a46db to 6adaa81 Compare June 5, 2026 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant