Problem/Motivation

The README.mdx file for the offcanvas component lists the backdrop property as a boolean, but if it is used this way it will not work correctly as the logic for setting a default value depends on a string.

If false is passed to this component instead of 'false' the resulting value from the following code will be 'true'.
{% set backdrop = backdrop|default('true') %}

The comments in offcanvas.twig accurately define this:
* - backdrop: (optional) Backdrop: 'true' | 'false' | 'static'.

The definition in README.mdx shows:
- `backdrop` (bool) (default: true): Backdrop.

Proposed resolution

Update the README, defining this as a string instead of a bool.

Issue fork radix-3526166

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

cyu created an issue. See original summary.

cyu’s picture

Status: Active » Needs review
cyu’s picture

Assigned: cyu » Unassigned

doxigo made their first commit to this issue’s fork.

  • doxigo committed bdfaf5c2 on 6.0.x authored by cyu
    Issue #3526166: Update property definition for backdrop in offcanvas...
doxigo’s picture

Status: Needs review » Fixed

Thanks a lot Christopher, merged and updated the https://radix.trydrupal.com/radix/components/offcanvas as well

I noticed some duplicates there as well, that aside I wonder if we should make that into a boolean instead of string.
Would appreciate another MR

cyu’s picture

Yeah, a value of "static" shouldn't be doing anything there, based on https://getbootstrap.com/docs/5.0/components/offcanvas/#options, so switching to boolean looks like the right move.

https://getbootstrap.com/docs/5.0/components/modal/#options accepts "static" plus boolean values, but that Radix modal component looks like it only supports setting to "static" or not setting a data-bs-backdrop value (defaulting to true), with no way to set data-bs-backdrop="false"

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.