Skip to content

prevent-link-loss - Workaround disappearing field Chrome bug - #9970

Open
Sebastien-Ahkrin wants to merge 6 commits into
refined-github:mainfrom
Sebastien-Ahkrin:fix-prevent-loss-comment
Open

prevent-link-loss - Workaround disappearing field Chrome bug#9970
Sebastien-Ahkrin wants to merge 6 commits into
refined-github:mainfrom
Sebastien-Ahkrin:fix-prevent-loss-comment

Conversation

@Sebastien-Ahkrin

@Sebastien-Ahkrin Sebastien-Ahkrin commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

prevent-link-loss was mounting its banner directly inside the closest fieldset or .CommentBox element. That result on github to a markdown editor with height at 0 hiding the comment textarea.

Closes: #9955

Tested on Safari, Chrome and Firefox

Test done to make my fix

The height will be 0 if we put the Banner direclty inside the target.

function attach(field: HTMLTextAreaElement): void {
	const target = closestElement([
		// Almost everywhere
		'fieldset',

		// Editing PR body
		'.CommentBox',
	], field);

	const before = target.getBoundingClientRect().height;
	
	mount(Banner, {
		target,
		props: {field},
	});

	requestAnimationFrame(() => {
		const after = target.getBoundingClientRect().height;
		const textareaRect = field.getBoundingClientRect();

		console.log(
			'target:', target.tagName, target.className,
			'height before:', before,
			'height after:', after,
			'textarea rect after:', textareaRect,
		);
	});
}

Will result to :
target: FIELDSET MarkdownEditor-module__fieldSet__RU0NL height before: 215.38284301757812 height after: 0 textarea rect after: DOMRect

CF : height after: 0

So the easier fix was to mount the banner as a sibling of the target instead of inside it

Test URLs

I will test with this link in my GIF : https://github.com/refined-github/refined-github/pull/6954/commits/32d1c8b2e1b6971709fe273cfdd1f959b51e8d85

Screenshot / GIF

Sorry for the screens they are at zoom 100% not 200% to see the entire feature. Hope this is still good

New issue form

CleanShot 2026-08-11 at 21 19 00

New comment form

CleanShot 2026-08-11 at 21 19 48

New review form

CleanShot 2026-08-11 at 21 20 43

New review comment form

CleanShot 2026-08-11 at 21 21 40

@github-actions github-actions Bot added the bug label Aug 11, 2026
@github-actions github-actions Bot changed the title fix(prevent-link-loss): mount banner outside the fieldset fix(prevent-link-loss): mount banner outside the fieldset Aug 11, 2026
@Sebastien-Ahkrin

Copy link
Copy Markdown
Contributor Author

Tell me if something looks wrong !

@Sebastien-Ahkrin
Sebastien-Ahkrin marked this pull request as ready for review August 11, 2026 19:43
@fregante

Copy link
Copy Markdown
Member

Thanks! No conventional commit here by the way

@Sebastien-Ahkrin

Copy link
Copy Markdown
Contributor Author

Thanks! No conventional commit here by the way

Oh ok ! Sorry, do you want me to rewrite my commits or its ok for this PR ?
For next PR I will do like your commits then !

Sorry !

@fregante

Copy link
Copy Markdown
Member

No the commits don't matter but the PR title does 😭

@Sebastien-Ahkrin Sebastien-Ahkrin changed the title fix(prevent-link-loss): mount banner outside the fieldset prevent-link-loss - Mount banner outside the fieldset Aug 11, 2026
Comment thread source/features/prevent-link-loss.tsx
@Sebastien-Ahkrin

Copy link
Copy Markdown
Contributor Author

No the commits don't matter but the PR title does 😭

Ok sorry ! I updated it then !

@Sebastien-Ahkrin
Sebastien-Ahkrin marked this pull request as draft August 11, 2026 21:49
@Sebastien-Ahkrin
Sebastien-Ahkrin marked this pull request as ready for review August 11, 2026 22:29
@fregante

Copy link
Copy Markdown
Member

Thanks for testing this extensively! I changed the code a bit and fixed some spacing mistakes I somehow did not notice in my previous PR

Old field

Screenshot 3

React fields

Screenshot 2 Screenshot 1 Screenshot

@fregante fregante changed the title prevent-link-loss - Mount banner outside the fieldset prevent-link-loss - Workaround disappearing field Chrome bug Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

prevent-link-loss hides the comment box in v26.8.8

2 participants