Skip to content

use filename when creating file via extension dropdown #7839

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

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

enjeck
Copy link
Contributor

@enjeck enjeck commented Sep 13, 2024

Description

Fixes #7385

Before

2024-09-13_06-30-06.mp4

After

2024-09-13_07-38-36.mp4

Checklist:

  • Testing instructions are provided, if not obvious
  • Release instructions are provided, if not obvious

@enjeck
Copy link
Contributor Author

enjeck commented Sep 13, 2024

cc @novoselt

@haraldschilly
Copy link
Contributor

hmm, I see, I wonder as well why the state isn't updated properly? My second thought is, is that dropdown-create activity used elsewhere as well, and hence there might be a problem overwriting the filename.

@enjeck
Copy link
Contributor Author

enjeck commented Sep 13, 2024

hmm, I see, I wonder as well why the state isn't updated properly? My second thought is, is that dropdown-create activity used elsewhere as well, and hence there might be a problem overwriting the filename.

I thought so too, that the dropdown might be overwriting it. But couldn't find any references there. I must be missing something

@williamstein
Copy link
Contributor

My guess is that this bug is because filename is in a closure (i.e., a function). filename is updated in the component, but the copy of the function createFile (etc.) that is actually called on submit is an older copy that has an old version of filename.

All this code used to be coffeescript with classes, and we migrated it over the years to typescript with functional components. This is one of those subtle traps that comes up in such migration. Often we leave the class methods as nested functions in the functional component (instead of further refactoring the code), which can cause bugs.

A fix is to get the value using some sort of reference, which is basically what you did.

@williamstein williamstein added PR-positive review ready to merge and removed PR-needs review labels Sep 13, 2024
@haraldschilly
Copy link
Contributor

@enjeck thank you for the PR, but we need a CLA (contributor license agreement) for all code contributions on file. It's just a standard document to clarify it can be used by CoCalc and the company behind. You do not have an email address on your github profile and I don't know how to contact you. So, please reach out to me ( hsy@cocalc.com ) and I'll send you a form.

@williamstein williamstein merged commit 3c6bf55 into sagemathinc:master Sep 13, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-positive review ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using extension dropdown ignores the entered filename
3 participants