Skip to content

quick-review - Fix opening "review now" link in a new tab#9408

Merged
SunsetTechuila merged 6 commits into
mainfrom
quick-review-new-tab
May 10, 2026
Merged

quick-review - Fix opening "review now" link in a new tab#9408
SunsetTechuila merged 6 commits into
mainfrom
quick-review-new-tab

Conversation

@SunsetTechuila

@SunsetTechuila SunsetTechuila commented May 9, 2026

Copy link
Copy Markdown
Contributor

Addresses #9259 (comment)

Test URLs

This PR

Screenshot

chrome_5LpFDO7uRA

Comment thread source/features/quick-review.tsx Outdated
);

// Occasionally this button appears before "Reviewers", so let's wait a bit longer
await delay(300);

@fregante fregante May 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is where a svelte/preact component would shine for example, we don't have to deal with this.

If I remember correctly I did try to load Preact years ago but our JSX types would conflict with it. Perhaps nowadays there are ways (via TS projects) to give dom-chef types to some files and preact types to others.

Anyway, good enough for now.

Comment thread source/features/quick-review.tsx Outdated
const isNewFilesChangedExperienceEnabled = (): boolean => $(prFilesChangedTabSelector).href.endsWith('changes');

async function quickApprove(event: DelegateEvent<MouseEvent>): Promise<void> {
async function quickApprove(event: React.MouseEvent): Promise<void> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

By the way, the reason why we use event delegation instead of inline handlers is that (at least in the past) GitHub would cache the DOM when going back and forth, but it would break any listeners (probably getting it via innerHTML). delegate works because global listeners are not removed this way.

I don't know if it's still the case and what views are affected. I've been using inline listeners for short-lived buttons, generally.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Noted. I'll revert this just in case

}

// Legacy PR files view -- TODO: Drop after it is removed
async function openReviewPopup(button: HTMLButtonElement): Promise<void> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please place callbacks before their usage. I like to start at the bottom, then see the inits above feature.add, then see the callbacks above the inits, and so on.

Not a strict rule (yet) but it makes it so much better to follow. See

@SunsetTechuila SunsetTechuila May 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is placed before its usage:

image

I know this rule and I hate it, though. It forces to read the code from bottom to top if you want to get a general idea of the logic without diving into the implementation details. And even this often doesn't work.

Not a strict rule (yet)

Better to make it if you like it. I'm surprised it’s not part of the xo config.

@SunsetTechuila SunsetTechuila May 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I know this rule and I hate it, though. It forces to read the code from bottom to top if you want to get a general idea of the logic without diving into the implementation details. And even this often doesn't work.

Clean Code has a chapter where it says to structure your code like the text of a book. I wish at least a fourth of the people who criticize CC on the internet had read at least that chapter

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm surprised it’s not part of the xo config.

I was too, not even mentioned anywhere in the xo org. I opened

I know this rule and I hate it, though. It forces to read the code from bottom to top

If the whole repo was set up in a way to red top to bottom, then perhaps it would make sense to do it, but this is not possible with const (including memoized functions).

Because of this, I can't think of a way other than bottom to top to read our features:

  1. look what pages it applies via includes at the bottom
  2. see what init does
  3. follow each function upwards

It is placed before its usage:

💙 👍

I saw initSidebarReviewButton above it so I assumed this block was "below some inits"

@fregante

Copy link
Copy Markdown
Member

We can merge this PR and think about #9327 later. The fix for that one is probably to observe a deeper element, if possible, so that we can detect when GitHub removes and re-creates it.

@SunsetTechuila SunsetTechuila merged commit 25d138f into main May 10, 2026
10 checks passed
@SunsetTechuila SunsetTechuila deleted the quick-review-new-tab branch May 10, 2026 10:30
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.

2 participants