Skip to content

Update admin-bar.blade.php: Fix uncaught TypeError for missing confirmationLink element on non-admin views#994

Open
thealexparadox wants to merge 1 commit into
LinkStackOrg:mainfrom
thealexparadox:patch-1
Open

Update admin-bar.blade.php: Fix uncaught TypeError for missing confirmationLink element on non-admin views#994
thealexparadox wants to merge 1 commit into
LinkStackOrg:mainfrom
thealexparadox:patch-1

Conversation

@thealexparadox

Copy link
Copy Markdown

Summary of Changes

This pull request resolves a runtime TypeError (can't access property "addEventListener", document.getElementById(...) is null) occurring on pages where the admin bar module is conditionally absent.

Root Cause

The inline script block inside admin-bar.blade.php unconditionally executes document.getElementById("confirmationLink").addEventListener(...) and attempts to read its attributes on every page load. When rendered on views lacking the administrative user deletion link, #confirmationLink evaluates to null, breaking client-side JavaScript execution globally for the UI.

Solution

  • Introduced a DOM existence check (if (confirmationLink)) around the event listener binding logic.
  • Added a corresponding null check inside the showConfirmation() helper function to safely verify element presence before attempting to fetch the href attribute.

Fix null reference error for confirmationLink on pages without admin bar
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