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

fix: Removed fixed width constraint from Save button #29686

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

goldjee
Copy link
Contributor

@goldjee goldjee commented Jul 24, 2024

SUMMARY

Currently, "Save" button in SQL Lab has fixed width. So, longer labels are trimmed. This is an attempt to fix that.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

English / before:
eng before

English / after:
Снимок экрана 2024-07-24 в 18 49 58

Russian / before:
Снимок экрана 2024-07-24 в 18 48 22

Russian / after:
Снимок экрана 2024-07-24 в 18 48 51

TESTING INSTRUCTIONS

Switch to any language that has long "Save" button translation. Russian, for example.

ADDITIONAL INFORMATION

  • Has associated issue: Fixes SQL Lab - Save button doesn't change its size based on label length #29477
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@dosubot dosubot bot added the change:frontend Requires changing the frontend label Jul 24, 2024
@michael-s-molina michael-s-molina added review:checkpoint Last PR reviewed during the daily review standup and removed review:checkpoint Last PR reviewed during the daily review standup labels Jul 24, 2024
@rusackas rusackas requested review from kgabryje and geido July 25, 2024 18:13
@rusackas
Copy link
Member

The Russian button obviously improved in the "after' screenshot, but is there a good way to do this so that the English button (or any language with a shorter string) doesn't take up extra space?

@goldjee
Copy link
Contributor Author

goldjee commented Jul 25, 2024

The Russian button obviously improved in the "after' screenshot, but is there a good way to do this so that the English button (or any language with a shorter string) doesn't take up extra space?

I've found line 39 at ./superset-frontend/src/components/DropdownButton/index.tsx that sets the standard width at 120px. If I remove this, the button won't take up extra space. This seems correct, because it will prevent other parts of the UI from label trimming. However, I'm hesitant to proceed since I don't know if this width was specified by design guidelines, or if changing it will break something.

I could also try modifying the CSS of the Save button to reset its width to auto.

Which solution is preferable?

@goldjee
Copy link
Contributor Author

goldjee commented Jul 26, 2024

I decided to roll with the second approach for now. Left core component as is and applied width: auto to the styled Save button itself. This is how it looks now:

EN RU

@mistercrunch
Copy link
Member

mistercrunch commented Jul 29, 2024

I think the reason why we were not using the default antd behavior in this area is because the SAVE button changes text dynamically when there's text selected as shown here, and we didn't want the button to change with when selecting/deselecting text.

Screenshot 2024-07-29 at 1 53 49 PM

Looks like your current width: auto overrides the larger fixed with. Seems the ideal situation would be to target the larger with to the specific button (instead of making all buttons on the component wider, and then overriding with auto). Can we do this instead?

@goldjee
Copy link
Contributor Author

goldjee commented Jul 30, 2024

@mistercrunch, thanks for the feedback, but I'm not sure that I'm following you. Upon reviewing the behavior when text is selected, I noticed that it's actually the "Run" button that changes its label, not the "Save" button. As my changes were targeted specifically at the SaveDatasetActionButton (not the DropdownButton or Button), the behavior you described is intact.

Probably the reason for my confusion is that I see "Run" as a plain button, not a dropdown one. Could you please clarify how I can get to the state depicted on your screenshot?

Снимок экрана 2024-07-30 в 07 12 18 Снимок экрана 2024-07-30 в 07 12 29

@mistercrunch
Copy link
Member

Sorry for the confusion, I thought some of the css you're changing here was around to support the fixed width on the "dynamically labeled" Run button, but looking at the code in more details now, it clearly is not the case.

Digging in - and that's not related to this PR directly, but I'm not sure why so much of this styling logic is in this file as opposed to simply being more vanilla antd, or simply living in the component library, but that's out of scope for this PR.

One question is whether the &:first-of-type { width: auto; } is necessary. Isn't that the default antd behavior?

@goldjee
Copy link
Contributor Author

goldjee commented Aug 1, 2024

One question is whether the &:first-of-type { width: auto; } is necessary. Isn't that the default antd behavior?

It seems that this is default indeed. I've tried to omit setting explicit auto width, but the button turned 120px wide. Looks like it's some sort of customization of Superset's UI kit.

I've found line 39 at ./superset-frontend/src/components/DropdownButton/index.tsx that sets the standard width at 120px.

@mistercrunch
Copy link
Member

mistercrunch commented Aug 2, 2024

Yup here's a link to it for reference. https://github.com/apache/superset/blob/master/superset-frontend/src/components/DropdownButton/index.tsx#L38

Curious why it's there in the first place, I'd almost advise to delete that line to see what happens. Should be min-width if anything, but I'd say drop that line and we can fix whatever it breaks later if/where needed in a more targeted/proper way, along with a comment that expalins why it's ther (ie // added this because of {intricate use case})`

@goldjee
Copy link
Contributor Author

goldjee commented Aug 3, 2024

@mistercrunch

Done!

@mistercrunch
Copy link
Member

/testenv up

@goldjee
Copy link
Contributor Author

goldjee commented Aug 22, 2024

Can I do something more for this PR to move forward?

Copy link
Member

@mistercrunch mistercrunch left a comment

Choose a reason for hiding this comment

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

LGTM

@mistercrunch
Copy link
Member

Approved, but looks like you're going to need to rebase to quick off the new required CI checks...

@mistercrunch
Copy link
Member

I wish we had something like this -> isaacs/github#88

@goldjee
Copy link
Contributor Author

goldjee commented Aug 23, 2024

Rebased

@mistercrunch
Copy link
Member

/testenv up

@mistercrunch
Copy link
Member

I think someone fixed the ephemeral environments, testing it here for giggles, will merge after confirming they work

@mistercrunch mistercrunch merged commit cb23d6f into apache:master Aug 23, 2024
34 checks passed
@goldjee goldjee deleted the sqllab-save-button-width branch August 23, 2024 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change:frontend Requires changing the frontend size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQL Lab - Save button doesn't change its size based on label length
4 participants