[GH-ISSUE #738] Mouse hoverring over renderable that gets removed can cause a crash #970

Closed
opened 2026-03-14 09:10:18 +03:00 by kerem · 0 comments
Owner

Originally created by @justfortheloveof on GitHub (Feb 24, 2026).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/738

I have this basic Link component:

import { useTheme } from '../../theme/index.ts';
import { ICONS } from '../../utils/icons.ts';
import { openInBrowser } from '../../utils/shell.ts';

type Props = {
	text: string;
	url: string;
};

export function Link(props: Props) {
	const theme = useTheme();
	return (
		<text
			onMouseUp={() => openInBrowser(props.url)}
			onMouseDown={function () {
				this.fg = theme.text;
			}}
			onMouseOver={function () {
				this.fg = theme.accent;
			}}
			onMouseOut={function () {
				this.fg = theme.text;
			}}
			fg={theme.text}
			wrapMode='none'
		>
			<span>{props.text}</span>
			<span style={{ fg: theme.accent }}>{ICONS.urlHint}</span>
		</text>
	);
}

It seemingly works fine, except when I use the Link component within a conditional Show component. If the condition flips and the Link component is no longer rendered while the mouse is still hovering over it, we crash with:

TextBuffer is destroyed
Originally created by @justfortheloveof on GitHub (Feb 24, 2026). Original GitHub issue: https://github.com/anomalyco/opentui/issues/738 I have this basic Link component: ```typescript import { useTheme } from '../../theme/index.ts'; import { ICONS } from '../../utils/icons.ts'; import { openInBrowser } from '../../utils/shell.ts'; type Props = { text: string; url: string; }; export function Link(props: Props) { const theme = useTheme(); return ( <text onMouseUp={() => openInBrowser(props.url)} onMouseDown={function () { this.fg = theme.text; }} onMouseOver={function () { this.fg = theme.accent; }} onMouseOut={function () { this.fg = theme.text; }} fg={theme.text} wrapMode='none' > <span>{props.text}</span> <span style={{ fg: theme.accent }}>{ICONS.urlHint}</span> </text> ); } ``` It seemingly works fine, except when I use the Link component within a conditional Show component. If the condition flips and the Link component is no longer rendered *while the mouse is still hovering over it*, we crash with: ``` TextBuffer is destroyed ```
kerem 2026-03-14 09:10:18 +03:00
  • closed this issue
  • added the
    bug
    label
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#970
No description provided.