Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MBS-12715, MBS-13526: ArtistCreditEditor refactor #3113

Merged
merged 3 commits into from Mar 27, 2024

Conversation

mwiencek
Copy link
Member

@mwiencek mwiencek commented Nov 28, 2023

This is based on top of #3111 since I use the new library for updating React state here.

Problem

The current ArtistCreditEditor has a number of issues:

  • It has no Flow types.
  • It's using old autocomplete/bubble components which also have no Flow types, and have been replaced by other components (Autocomplete2, ButtonPopover).
  • It's using ugly hacks to keep the bubble in sync with the editor component, instead of createPortal.
  • It's written as a class-based component, which React no longer recommends.
  • It maintains its own internal React state which must be synchronized with other view models from the inside, instead of being stateless and fully controlled by parent components.
  • It logs of bunch of warnings due to incorrect usage of flushSync.

In case the motivation is not clear: the above issues currently make it difficult to use the ArtistCreditEditor in future edit forms, like the React conversion of the release editor, and the "alternative tracklists" editor.

Solution

This basically refactors the entire component and its sub-components, and updates a lot of glue code that keeps it in sync with Knockout observables in the release, recording, and release group edit forms.

Testing

Just manual testing so far in the release, recording, and release group edit forms.

  • Copying/pasting artist credits.
  • Using "guess feat. artists" in the recording edit form.
  • Moving between tracks in the release editor, including using the enter key.

@mwiencek mwiencek force-pushed the artist-credit-editor-refactor branch from 077d26f to 38ac43b Compare November 28, 2023 17:08
Copy link
Member

@reosarevok reosarevok left a comment

Choose a reason for hiding this comment

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

Lots to go yet, few comments for now.

@mwiencek mwiencek force-pushed the artist-credit-editor-refactor branch 6 times, most recently from 175d19b to d150ce0 Compare December 6, 2023 00:37
@mwiencek mwiencek force-pushed the artist-credit-editor-refactor branch 3 times, most recently from f068256 to 8402a91 Compare December 6, 2023 22:47
@mwiencek
Copy link
Member Author

mwiencek commented Dec 6, 2023

Finally got tests working here. Many of the failures revealed actual bugs, all of which I've fixed, but other failures were simply due to the HTML of the autocompletes changing.

@mwiencek mwiencek added React PRs directly related with React conversion Refactoring Refactoring-only PRs (eslint fixes etc) labels Dec 12, 2023
@mwiencek mwiencek force-pushed the artist-credit-editor-refactor branch 2 times, most recently from aa9ce6f to 35d3331 Compare December 13, 2023 18:38
@reosarevok
Copy link
Member

Tested this locally, seems to work fine - except for the automatic feat. standardization, but that's good since that hasn't been our guideline for years now so that code should be removed anyway. Do check if other join phrase standardizations are still wanted though that also fail?

Copy link
Member

@reosarevok reosarevok left a comment

Choose a reason for hiding this comment

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

Some comments, checking this up to the start of the release-editor folder.

@@ -87,7 +88,7 @@ function entityHref(
break;

default:
if (entityProps.mbid && entity.gid) {
if (entityProps.mbid && nonEmpty(entity.gid)) {
Copy link
Member

Choose a reason for hiding this comment

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

How does nonEmpty work on knockout observables? Would it always see it as non-empty even if the T in Observable<T> is ''?

Copy link
Member Author

Choose a reason for hiding this comment

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

It would always see it as non-empty, yes. But the nonEmpty call was mainly added to work around a sketchy-null error from Flow. If the unwrapped gid is empty, entityHref will return a nonsense result either way (because id will just remain an empty string).

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm guessing that's why I originally added #3113 (comment) though.

root/static/scripts/edit/components/ArtistCreditBubble.js Outdated Show resolved Hide resolved
root/static/scripts/edit/components/ArtistCreditBubble.js Outdated Show resolved Hide resolved
root/static/scripts/edit/components/ArtistCreditBubble.js Outdated Show resolved Hide resolved
@mwiencek mwiencek force-pushed the artist-credit-editor-refactor branch from 35d3331 to adef368 Compare January 29, 2024 16:35
@reosarevok
Copy link
Member

There's a conflict here, but in general maybe we should put this on test?

@mwiencek mwiencek force-pushed the artist-credit-editor-refactor branch 2 times, most recently from 1cfdb45 to c727909 Compare February 16, 2024 18:03
@mwiencek
Copy link
Member Author

There's a conflict here, but in general maybe we should put this on test?

Sure, I've rebased and put it on the test server now. :)

@reosarevok
Copy link
Member

reosarevok commented Feb 19, 2024

Few comments from testing on test.mb (mostly works just fine AFAICT, these are all comments or very small issues):

  1. Is it intentional that the popover takes less space than before, and that "Done" is no longer right-aligned? (I assume the change from grey to white is intentional since it shows the buttons a lot more clearly)
  2. Is it intentional that the entered credit is kept when blanking the artist field with the keyboard, but only if it differs from the default fro the artist being deleted? (seems useful but it differs from prod where it seemingly always gets removed when blanking the field, so making sure it's a feature and not a bug)
  3. Do we store at all the [removed] entries in state? Would it be possible to un-remove if I click by mistake? (before it was annoying to misclick but you sighed and moved on... but now it reminds you it knows there was something, so it kinda feels you should be able to get it back!)
  4. If I have at least two empty artist fields, I can end up with multiple Recent items dropdowns at once. It seems to mostly be reproduceable by clicking one empty field, clicking somewhere else, then clicking the other empty field, see:
    Peek 2024-02-19 16-02
  5. Probably the weirdest nitpick ever, but in case it might show some other underlying issue: if I blank a join phrase between artists 1 and 2, then I add artist 3, the blanked phrase remains blanked. If I paste an AC with a blank join phrase between artists 1 and 2, then I add artist 3, the blanked phrase turns into , .
  6. More nitpicking: Does the positioning of the search icon look weird to you in the release tracklist? It does to me, it kinda feels like it should be either also green so it looks like the artist field, or exactly in the center of the white square?
    Screenshot from 2024-02-19 16-22-43
  7. Semi-relatedly, should we grey out that search icon or have a hover text or something so that it is clearer that it will work for track 1 here but not track 2? (this is not a new issue but for some reason - probably because the icon is bigger now - it feels more annoying than before). It still shows "Search" on hover, maybe it could at least show "Cannot search for multiple artists" or something?
    Screenshot from 2024-02-19 16-24-48

@yvanzo
Copy link
Contributor

yvanzo commented Mar 5, 2024

Also when removing a name, the line stays with [removed] and the red cross button, whereas in production the line just disappears.

@yvanzo
Copy link
Contributor

yvanzo commented Mar 5, 2024

ArtistCreditEditor refactor (including MBS-12715)

It still is the main change here so the usual MBS-12715: Refactor artist credit editor would do.

@reosarevok
Copy link
Member

The [removed] thing is expected, it's apparently an accessibility thing (that's why the relationship editor already does it).

@yvanzo
Copy link
Contributor

yvanzo commented Mar 5, 2024

The [removed] thing is expected, it's apparently an accessibility thing (that's why the relationship editor already does it).

Ok, I guess that it is a first step towards your above point 3 about un-removing (as the relationship editor already does it).

@mwiencek
Copy link
Member Author

Is it intentional that the popover takes less space than before

Do you mean more space? I had increased the max-width, and it's clearly bigger for me.

and that "Done" is no longer right-aligned?

Fixed

I assume the change from grey to white is intentional since it shows the buttons a lot more clearly

I changed it back to gray, since nobody complained about it before

Is it intentional that the entered credit is kept when blanking the artist field with the keyboard, but only if it differs from the default fro the artist being deleted? (seems useful but it differs from prod where it seemingly always gets removed when blanking the field, so making sure it's a feature and not a bug)

I'm not sure if this was intentional, but if you prefer the behavior we could keep it.

Do we store at all the [removed] entries in state? Would it be possible to un-remove if I click by mistake? (before it was annoying to misclick but you sighed and moved on... but now it reminds you it knows there was something, so it kinda feels you should be able to get it back!)

You can undo them now

If I have at least two empty artist fields, I can end up with multiple Recent items dropdowns at once. It seems to mostly be reproduceable by clicking one empty field, clicking somewhere else, then clicking the other empty field, see: [...]

Fixed

Probably the weirdest nitpick ever, but in case it might show some other underlying issue: if I blank a join phrase between artists 1 and 2, then I add artist 3, the blanked phrase remains blanked. If I paste an AC with a blank join phrase between artists 1 and 2, then I add artist 3, the blanked phrase turns into , .

Fixed

More nitpicking: Does the positioning of the search icon look weird to you in the release tracklist? It does to me, it kinda feels like it should be either also green so it looks like the artist field, or exactly in the center of the white square?

I tweaked the positioning and it turns green now. (However, this looks kinda weird for inputs that still have a border -- unlike the ones in the tracklist.)

Semi-relatedly, should we grey out that search icon or have a hover text or something so that it is clearer that it will work for track 1 here but not track 2? (this is not a new issue but for some reason - probably because the icon is bigger now - it feels more annoying than before). It still shows "Search" on hover, maybe it could at least show "Cannot search for multiple artists" or something?

This sounds like a good idea, but I'm not actually sure how to gray out the icon (and it's an Autocomplete2 issue, not an ArtistCreditEditor issue -- I'd prefer to work on other improvements later).

@mwiencek mwiencek force-pushed the artist-credit-editor-refactor branch from d288533 to fde41e7 Compare March 27, 2024 16:25
This is to allow preserving the same input id format in the artist credit
editor.

If we really want '-input' in the id, we can still pass it to the component
that way.
@mwiencek mwiencek force-pushed the artist-credit-editor-refactor branch from fde41e7 to 5cb5f9e Compare March 27, 2024 16:26
Copy link
Contributor

@yvanzo yvanzo left a comment

Choose a reason for hiding this comment

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

It looks good to me. I didn’t test the latest changes but you obviously did.

Just a couple of minor tidying-up points:

  • “Removal undoing” at least seems to be worth a separate ticket.
  • The PR title should start to with the addressed ticket(s) as usual, even though some more refactoring is done as well.

 * Uses the new `ButtonPopover` component.

 * Uses the new `Autocomplete2` component (MBS-12715).

 * Replaces the nasty `ArtistCreditBubble` update hacks with
   `createPortal`.

 * Converts everything into "stateless" (as in, no internal state)
   functional components.

 * Adds Flow types.

 * Fixes a usability issue with removing items by keeping focus on the
   current [X] and replacing the deleted row with [removed]. See
   https://ux.stackexchange.com/a/99411.

 * Adds support for undoing removals (MBS-13526).
@mwiencek mwiencek force-pushed the artist-credit-editor-refactor branch from 5cb5f9e to 8cef6e9 Compare March 27, 2024 17:00
@mwiencek
Copy link
Member Author

mwiencek commented Mar 27, 2024

The PR title should start to with the addressed ticket(s) as usual, even though some more refactoring is done as well.
“Removal undoing” at least seems to be worth a separate ticket.

Apologies, since you'd suggested that previously in #3113 (comment) but I forgot to apply the changes.

I also opened MBS-13526 for the undo button.

@mwiencek mwiencek changed the title ArtistCreditEditor refactor (including MBS-12715) MBS-12715, MBS-13526: ArtistCreditEditor refactor Mar 27, 2024
@mwiencek mwiencek merged commit c2286bf into metabrainz:master Mar 27, 2024
2 of 3 checks passed
@mwiencek mwiencek deleted the artist-credit-editor-refactor branch March 27, 2024 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
React PRs directly related with React conversion Refactoring Refactoring-only PRs (eslint fixes etc)
Projects
None yet
4 participants