Skip to content

Fix TypeError when popover/tooltip title or content is "true"/"false"#42155

Draft
Copilot wants to merge 2 commits intov6-devfrom
copilot/fix-popover-data-bs-content-issue
Draft

Fix TypeError when popover/tooltip title or content is "true"/"false"#42155
Copilot wants to merge 2 commits intov6-devfrom
copilot/fix-popover-data-bs-content-issue

Conversation

Copy link
Contributor

Copilot AI commented Mar 11, 2026

normalizeData in manipulator.js coerces the strings "true"/"false" from data attributes into booleans, but title and content config options only accept string|element|function|null — causing a TypeError on type check.

Changes:

  • js/src/tooltip.js — Extended _configAfterMerge to convert boolean title/content values to their string representations, mirroring the existing number-to-string handling
  • js/tests/unit/tooltip.spec.js — Added test case alongside the existing numeric conversion test
<!-- Previously threw TypeError, now renders "true" as content -->
<button data-bs-toggle="popover" data-bs-content="true">Show "true"</button>
Original prompt

This section details on the original issue you should resolve

<issue_title>[Popover] data-bs-content="true"/"false" auto-converted to boolean causes TypeError, but "true"/"false" are valid string content.</issue_title>
<issue_description>### Prerequisites

Describe the issue

When using data-bs-content="true" (or "false") on an element with data-bs-toggle="popover", Bootstrap internally converts the string "true" to the boolean true, causing _typeCheckConfig to throw:

TypeError: POPOVER: Option "content" provided type "boolean" but expected type "(null|string|element|function)".

This prevents users from displaying the literal string "true" or "false" — a common and valid use case (e.g., showing boolean-like values in tables, configs, JSON previews).

Reduced test cases

  1. Add this HTML:
    <button type="button" class="btn btn-secondary" data-bs-toggle="popover" data-bs-content="true"> Show "true" </button>

  2. Initialize popovers (e.g., via new bootstrap.Popover() or auto-init via data-bs-toggle).

  3. Observe console error:
    TypeError: POPOVER: Option "content" provided type "boolean" but expected type "(null|string|element|function)".

What operating system(s) are you seeing the problem on?

Windows

What browser(s) are you seeing the problem on?

Chrome

What version of Bootstrap are you using?

v5.2.1</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: mdo <98681+mdo@users.noreply.github.com>
Copilot AI changed the title [WIP] [Popover] Fix TypeError for string content values Fix TypeError when popover/tooltip title or content is "true"/"false" Mar 11, 2026
Copilot finished work on behalf of mdo March 11, 2026 23:37
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