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

Change button state before event process #1866

Merged

Conversation

hitaishi19
Copy link
Contributor

@hitaishi19 hitaishi19 commented Dec 3, 2024

Description

Save button does not show loading state when clicking on it. Instead it remains still for sometime and then shows loading state. This is due to event being fully processed before setting the loading class and disabling the button.

Manual testing steps

Issues

Pull request checklist

  • The target branch is correct
  • All commits are relevant to the purpose of the PR (e.g. no debug statements, unrelated refactoring, or arbitrary linting)
    • Small amounts of additional linting are usually okay, but if it makes it hard to concentrate on the relevant changes, ask for the unrelated changes to be reverted, and submitted as a separate PR.
  • The commit messages follow our commit message guidelines
  • The PR follows our contribution guidelines
  • Code changes follow our coding conventions
  • This change is covered with tests (or tests aren't necessary for this change)
  • Any relevant User Help/Developer documentation is updated; for impactful changes, information is added to the changelog for the intended release
  • CI is green

@hitaishi19 hitaishi19 marked this pull request as ready for review December 3, 2024 19:06
Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

I've added the pull request template back into the PR description. Can you please fill it in, including ticking all of the checkboxes that apply? This will help you identify things that need to be done before this is ready to be reviewed (for example build the dist javascript).

Please also retarget this PR to the 2.3 branch so that it can be included as a patch release rather than waiting for the next minor release.
You may need to reset your commits after retargetting the PR.

I have also tested this locally and found two problems:

  1. Instead of swapping to the "loading" appearance, the button goes completely blank:
    image
    It only uses the full loading styling after the beforesubmitform stuff has finished.
    An easy way to test this is to add a sleep(5) into the validate() method of an elemental block, then make sure to edit the block before hitting save.
  2. If an elemental block has a validation error, the button stays disabled forever.

@GuySartorelli
Copy link
Member

GuySartorelli commented Dec 6, 2024

To fix 1, probably you need to move everything in the if($(button).is('button')) { conditional block.

To fix 2, I suspect the clearButton() function needs to be called in the if (!success) { conditional block just before it returns false.

@hitaishi19 hitaishi19 changed the base branch from 2 to 2.3 December 8, 2024 21:52
@hitaishi19 hitaishi19 changed the base branch from 2.3 to 2 December 8, 2024 21:53
@hitaishi19 hitaishi19 changed the base branch from 2 to 2.3 December 8, 2024 21:58
@hitaishi19 hitaishi19 force-pushed the bugfix/save-button-loading-issue branch 2 times, most recently from 32c8250 to 8cd82d6 Compare December 9, 2024 02:02
Previously, Save button remains as it is after clicking on it with api call
in background. Now, we enabled loading UI on button when start processing
@hitaishi19 hitaishi19 force-pushed the bugfix/save-button-loading-issue branch from 8cd82d6 to 6f1e8a2 Compare December 9, 2024 02:09
client/src/legacy/LeftAndMain.js Outdated Show resolved Hide resolved
@GuySartorelli
Copy link
Member

Problem 2 from #1866 (review) is still happening. Did you test that scenario?

@hitaishi19
Copy link
Contributor Author

Problem 2 from #1866 (review) is still happening. Did you test that scenario?

This is not reproducing to me, can you please share the reproduction steps?

@GuySartorelli
Copy link
Member

  1. Create a block
  2. Add some validation to an elemental block which will fail
    public function validate()
    {
        $result = parent::validate();
        $result->addFieldError('Title', 'FAILURE');
        return $result;
    }
  3. Make a change to the block (or else validation won't trigger)
  4. Click "save" on the page.

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

LGTM, works well locally. Thanks for taking the time to implement this fix.

@GuySartorelli GuySartorelli merged commit 0eb927c into silverstripe:2.3 Dec 9, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants