quick-review - Fix opening "review now" link in a new tab#9408
Conversation
| ); | ||
|
|
||
| // Occasionally this button appears before "Reviewers", so let's wait a bit longer | ||
| await delay(300); |
There was a problem hiding this comment.
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.
| const isNewFilesChangedExperienceEnabled = (): boolean => $(prFilesChangedTabSelector).href.endsWith('changes'); | ||
|
|
||
| async function quickApprove(event: DelegateEvent<MouseEvent>): Promise<void> { | ||
| async function quickApprove(event: React.MouseEvent): Promise<void> { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
It is placed before its usage:
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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:
- look what pages it applies via
includesat the bottom - see what init does
- follow each function upwards
It is placed before its usage:
💙 👍
I saw initSidebarReviewButton above it so I assumed this block was "below some inits"
|
We can merge this PR and think about #9327 later. The fix for that one is probably to |
Addresses #9259 (comment)
Test URLs
This PR
Screenshot