Skip to content

fix(popover): DLT-3550 guard focusFirstElementIfNeeded against unset content ref - #1407

Merged
Brad Paugh (braddialpad) merged 2 commits into
nextfrom
fix/dlt-3550-popover-null-focus-crash
Sep 3, 2026
Merged

fix(popover): DLT-3550 guard focusFirstElementIfNeeded against unset content ref#1407
Brad Paugh (braddialpad) merged 2 commits into
nextfrom
fix/dlt-3550-popover-null-focus-crash

Conversation

@braddialpad

Copy link
Copy Markdown
Contributor

Summary

  • Fixes a null-pointer crash in focusFirstElementIfNeeded when a delayed after-enter transition callback fires against a stale/unset $refs.content (e.g. main thread blocked during the enter transition).
  • returnFirstEl(this.$refs.content?.$el) can resolve to null; the fallback .focus() call is now optionally chained, matching the existing null-safety pattern used elsewhere in the same file (focusInitialElement, focusInitialElementById).
  • Adds a regression test that reproduces the stale-ref scenario for the "no focusable elements, showCloseButton false" fallback branch.

Jira: DLT-3550 (https://dialpad.atlassian.net/browse/DLT-3550)

Test plan

  • pnpm nx run dialtone-vue:test - Popover.test.js: 59 passed, 2 skipped
  • New test reproduces the crash without the fix and passes with the fix applied

…content ref

A delayed after-enter callback can fire against a stale $refs.content when
the main thread is blocked during the enter transition, causing
returnFirstEl(...) to return null and crash on .focus().
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Please add either the visual-test-ready or no-visual-test label to this PR depending on whether you want to run visual tests or not.
It is recommended to run visual tests if your PR changes any UI. ‼️

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Workspace UI (inherited)

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 97cb2199-033d-4edb-9760-720a312a4742

📥 Commits

Reviewing files that changed from the base of the PR and between 217f154 and f50b69e.

📒 Files selected for processing (2)
  • packages/dialtone-vue/components/Popover/Popover.test.js
  • packages/dialtone-vue/components/Popover/Popover.vue
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • dialpad/ios (manual)
  • dialpad/firespotter (manual)

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


Updated focusFirstElementIfNeeded to avoid a null-pointer crash when $refs.content is stale or unset. Added a regression test for popovers without focusable content or a close button.

Overall Judgement: ✅ Ready to merge — The fix is narrowly scoped and tested with 59 passing tests and 2 skipped tests.

Walkthrough

The popover fallback focus path now tolerates an unavailable content reference. A regression test covers delayed focus execution after the reference becomes unset.

Changes

Popover focus safety

Layer / File(s) Summary
Guard fallback focus and test stale references
packages/dialtone-vue/components/Popover/Popover.vue, packages/dialtone-vue/components/Popover/Popover.test.js
The fallback focus operation uses optional chaining. The test verifies that delayed focus does not throw when the content reference is unavailable.

Suggested reviewers: francisrupert, iropolo, ninarepetto, belumontoya, paulojreis-dialpad

Merge Risk: ⚪ Minimal · up to f50b6

This change prevents a popover focus callback from throwing when its content is unavailable and includes regression coverage for the affected fallback path. No actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Docs-To-Code Alignment ✅ Passed PASS. The net PR diff changes only packages/dialtone-vue/components/Popover/Popover.vue and its regression test; it does not change CLI commands, configuration options, public props, events, or sign…
Disabled Test Tracking ✅ Passed The PR does not neutralize any test. The Popover commit adds a normal describe block and a normal it regression test, with no skip, ignore, disable, expected-failure, exclusion, or rename change. …
Full details: Docs-To-Code Alignment

Explanation

PASS. The net PR diff changes only packages/dialtone-vue/components/Popover/Popover.vue and its regression test; it does not change CLI commands, configuration options, public props, events, or signatures. The code change only prevents .focus() from throwing when an internal stale $refs.content is absent. Existing Popover documentation still accurately describes the normal focus behavior, and this edge-case crash guard does not make that documentation stale.

Full details: Disabled Test Tracking

Explanation

The PR does not neutralize any test. The Popover commit adds a normal describe block and a normal it regression test, with no skip, ignore, disable, expected-failure, exclusion, or rename change. The existing it.skip and describe.skip markers are identical before and after the commit.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dlt-3550-popover-null-focus-crash

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

✔️ Deploy previews ready!
😎 Dialtone documentation preview: https://dialtone.dialpad.com/deploy-previews/pr-1407/
😎 Dialtone-vue preview: https://dialtone.dialpad.com/vue/deploy-previews/pr-1407/

@braddialpad
Brad Paugh (braddialpad) merged commit 7ebddf4 into next Sep 3, 2026
19 checks passed
@braddialpad
Brad Paugh (braddialpad) deleted the fix/dlt-3550-popover-null-focus-crash branch September 3, 2026 00:08
Brad Paugh (braddialpad) pushed a commit that referenced this pull request Sep 4, 2026
# [3.225.0-next.8](dialtone-vue/v3.225.0-next.7...dialtone-vue/v3.225.0-next.8) (2026-09-04)

### Bug Fixes

* **Popover:** DLT-3550 guard focusFirstElementIfNeeded against unset content ref ([#1407](#1407)) ([7ebddf4](7ebddf4))

### Documentation

* DLT-3431 redesign next doc site ([#1405](#1405)) ([7f4e798](7f4e798))
Brad Paugh (braddialpad) pushed a commit that referenced this pull request Sep 4, 2026
# [10.0.0-next.20](dialtone/v10.0.0-next.19...dialtone/v10.0.0-next.20) (2026-09-04)

### Bug Fixes

* **Popover:** DLT-3550 guard focusFirstElementIfNeeded against unset content ref ([#1407](#1407)) ([7ebddf4](7ebddf4))

### Documentation

* DLT-3431 redesign next doc site ([#1405](#1405)) ([7f4e798](7f4e798))
* NO-JIRA ensure deep-linked active side within view ([#1409](#1409)) ([9618ddd](9618ddd))

### Features

* DLT-3590 add package support for redesigned docs ([#1404](#1404)) ([8aa6b0b](8aa6b0b))
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