Skip to content

[tooltip] Fix error is thrown when wrapping an input which is disabled while focused#47684

Merged
ZeeshanTamboli merged 14 commits intomui:masterfrom
ZeeshanTamboli:issue-45373-tooltip-input
Feb 23, 2026
Merged

[tooltip] Fix error is thrown when wrapping an input which is disabled while focused#47684
ZeeshanTamboli merged 14 commits intomui:masterfrom
ZeeshanTamboli:issue-45373-tooltip-input

Conversation

@ZeeshanTamboli
Copy link
Copy Markdown
Member

@ZeeshanTamboli ZeeshanTamboli commented Jan 26, 2026

Closes #45373

If event is not passed like in the case of InputBase onBlur, we access the childNode.

Added an integration test.

Before: https://codesandbox.io/p/sandbox/objective-cray-qz8g4m
After: https://stackblitz.com/edit/fuvbkeou?file=src%2FApp.tsx

@mui-bot
Copy link
Copy Markdown

mui-bot commented Jan 26, 2026

Netlify deploy preview

https://deploy-preview-47684--material-ui.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/material 🔺+166B(+0.03%) 🔺+80B(+0.05%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against d17892a

@ZeeshanTamboli ZeeshanTamboli changed the title [tooltip] Fix issue that when wrapping an input which is disabled while focused an error is thrown [tooltip] Fix issue when wrapping an input which is disabled while focused an error is thrown Jan 26, 2026
@ZeeshanTamboli ZeeshanTamboli changed the title [tooltip] Fix issue when wrapping an input which is disabled while focused an error is thrown [tooltip] Fix error is thrown when wrapping an input which is disabled while focused Jan 28, 2026
@ZeeshanTamboli ZeeshanTamboli marked this pull request as ready for review January 28, 2026 12:58
@ZeeshanTamboli
Copy link
Copy Markdown
Member Author

Can this be reviewed?

Copy link
Copy Markdown
Member

@mj12albert mj12albert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From codex review:
onClose receives new Event('blur') which can have a null target, a safe approach is to keep a synthetic event and stamp target/currentTarget from childNode:

const target = event?.target ?? childNode;
const closeEvent = event ?? new Event('blur');

if (!event && target) {
  Object.defineProperty(closeEvent, 'target', { value: target });
  Object.defineProperty(closeEvent, 'currentTarget', { value: target });
}

handleMouseLeave(closeEvent);

@ZeeshanTamboli
Copy link
Copy Markdown
Member Author

ZeeshanTamboli commented Feb 12, 2026

From codex review: onClose receives new Event('blur') which can have a null target, a safe approach is to keep a synthetic event and stamp target/currentTarget from childNode:

const target = event?.target ?? childNode;
const closeEvent = event ?? new Event('blur');

if (!event && target) {
  Object.defineProperty(closeEvent, 'target', { value: target });
  Object.defineProperty(closeEvent, 'currentTarget', { value: target });
}

handleMouseLeave(closeEvent);

@mj12albert Makes sense. Updated the logic. Most of the time this logic won't run.

@ZeeshanTamboli ZeeshanTamboli added v7.x needs cherry-pick The PR should be cherry-picked to master after merge. labels Feb 18, 2026
@ZeeshanTamboli
Copy link
Copy Markdown
Member Author

Can this be reviewed?

Copy link
Copy Markdown
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ZeeshanTamboli ZeeshanTamboli merged commit fbddef4 into mui:master Feb 23, 2026
19 checks passed
@ZeeshanTamboli ZeeshanTamboli deleted the issue-45373-tooltip-input branch February 23, 2026 12:25
@github-actions
Copy link
Copy Markdown

Cherry-pick PRs will be created targeting branches: v7.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs cherry-pick The PR should be cherry-picked to master after merge. scope: tooltip Changes related to the tooltip. type: bug It doesn't behave as expected. v7.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Tooltip] When wrapping an input which is disabled while focused an error is thrown

4 participants