Skip to content

fix(ClosePopup&Ripple): allow undefined in the directive value type - #18605

Merged
rstoenescu merged 1 commit into
quasarframework:devfrom
mr-zwets:fix/directive-value-undefined
Nov 26, 2026
Merged

rstoenescu merged 1 commit into
quasarframework:devfrom
mr-zwets:fix/directive-value-undefined

Conversation

@mr-zwets

@mr-zwets mr-zwets commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

On behalf of Mathieu G. (mr-zwets), written by Claude Opus 5.5:

What changes and why

v-close-popup and v-ripple without a value are the documented default forms, and both directives handle it at runtime: for a value-less directive Vue passes binding.value === undefined, which ClosePopup.js treats as depth 1 (getDepth) and Ripple.js as enabled (value !== false). The ClosePopup.json description also says "if value is 1 or 'true' or undefined then it closes only the parent popup".

The API JSON leaves undefined out of the value type, so the generated types are

export type ClosePopupValue = boolean | number | string;
export type RippleValue = boolean | { /* ... */ };

while Vue's DirectiveBinding<Value> has value: Value, so the types reject the form the runtime and the docs use. Type checkers that check a value-less directive's binding report every use: Vue Language Tools types that value as undefined since vuejs/language-tools#6335 (merged, not yet released), and its v4 type checker reports the error once per use:

Type 'undefined' is not assignable to type 'ClosePopupValue'.

This adds "undefined" to value.type in ClosePopup.json and Ripple.json, as the Scroll, ScrollFire and Touch* directives already have.

Breaking change?

No. The value types only widen.

How was it validated?

  • Added an as undefined value test to ClosePopup.test.js, matching the one in Scroll.test.js (Ripple already has a no value test). The ClosePopup and Ripple test files pass, and so does pnpm test:specs:check.
  • Rebuilt the types (pnpm build js types): ClosePopupValue and RippleValue now end in | undefined. This file failed with TS2322 on both lines against the old types and compiles against the new ones:
import type { ClosePopup, Ripple } from 'quasar';
import type { Directive } from 'vue';

type ValueOf<D> = D extends Directive<any, infer V, any, any> ? V : never;

// what Vue passes for `<q-btn v-close-popup>` / `<div v-ripple>`
const closePopupValue: ValueOf<ClosePopup> = undefined;
const rippleValue: ValueOf<Ripple> = undefined;

Docs

None needed: the docs pages render the directives' API from the same JSON, and the ClosePopup description already mentions undefined.

Summary by CodeRabbit

  • Documentation
    • Updated the close-popup and ripple directive documentation to include undefined as an accepted value type. This clarifies that these directives may be used without an explicit value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

ClosePopup and Ripple metadata now include undefined among accepted directive value types. A ClosePopup test checks that omitting the value defaults to depth 1 when a click closes portals.

Changes: Directive value handling

Layer / File(s) Summary
Undefined value types and ClosePopup default
ui/src/directives/close-popup/ClosePopup.json, ui/src/directives/close-popup/ClosePopup.test.js, ui/src/directives/ripple/Ripple.json
Both directives’ value type lists include undefined. The ClosePopup test verifies that an omitted value uses depth 1 when a click closes portals.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested labels: area/ui

Suggested reviewers: rstoenescu

Merge Risk: Minimal · up to 78332

This widens the accepted value types for the ClosePopup and Ripple directives so that using them without a value type-checks. Existing usage is unaffected and merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed Title follows the conventional commit format with type fix and scope ClosePopup&Ripple. It names the main change: adding undefined to the directive value types. The title uses an HTML-escaped ampersan…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Undocumented Breaking Change Passed The check applies to breaking changes to public APIs. The diff changes only two API JSON files, and both change the same value type. ui/src/directives/close-popup/ClosePopup.json gains "undefined"…
Full details: Title check

Explanation

Title follows the conventional commit format with type fix and scope ClosePopup&Ripple. It names the main change: adding undefined to the directive value types. The title uses an HTML-escaped ampersand in the scope, which is a literal '&amp;' in the raw title text, so it should read '&' for correct display.

Full details: Undocumented Breaking Change

Explanation

The check applies to breaking changes to public APIs. The diff changes only two API JSON files, and both change the same value type. ui/src/directives/close-popup/ClosePopup.json gains "undefined" in value.type, and ui/src/directives/ripple/Ripple.json gains "undefined" in value.type. The test file adds a no-value test case. Adding undefined to an accepted input type widens the type. Existing callers that pass Boolean, Number, String, or Object values still type-check and behave as before. The runtime behavior of ClosePopup and Ripple does not change, and the PR already documents the value-less form. The change does not introduce a breaking change, so no breaking-change label or description callout is required. The PR description states "Breaking change? No" with a reason.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 16637f6 and 78332a2.

Files selected for processing: 3

  • ui/src/directives/close-popup/ClosePopup.json
  • ui/src/directives/close-popup/ClosePopup.test.js
  • ui/src/directives/ripple/Ripple.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@rstoenescu
rstoenescu merged commit 0ec690e into quasarframework:dev Nov 26, 2026
1 check passed
@rstoenescu

Copy link
Copy Markdown
Member

Thank you for catching this and contributing with a fix!

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.

2 participants