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

feat: implement number field debouncing #998

Merged
merged 2 commits into from
Jan 26, 2024
Merged

Conversation

Skaiir
Copy link
Contributor

@Skaiir Skaiir commented Jan 20, 2024

Closes #958
(again)

After a lot of reworks and problems I finally got this sorted.
For testing, make sure the debouncing is working, cleaning up when tabbing out. This should debounce when holding up or down arrow, when typing, and when clicking the arrows via the mouse.

I've also as part of this removed some problem things, like the fact that we were still sending an onChange with 'NaN' (a concept we had removed, but not fully, via #894), the test case is respectively changed.

What we are keeping is the NaN state when pasting something that's not a valid number, this is only visual and is here to give users feedback, otherwise they might think pasting just doesn't do anything. In the future a toast element might be more appropriate. Anyways this state is also more robust now.

@bpmn-io-tasks bpmn-io-tasks bot added the needs review Review pending label Jan 20, 2024
@github-actions github-actions bot temporarily deployed to demo-958-2-debounce-numberfiel January 20, 2024 15:10 Destroyed
if (incrementValue) return Big(incrementValue);
if (decimalDigits) return Big(`1e-${decimalDigits}`);
return Big('1');
useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can take out the useEffect here and just have the if statement running in the render.


const previousValue = usePrevious(value);

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above. Don't know if you need this wrapped in useEffect

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah probably not, but then again it does encapsulate the behavior in a nice block. I mean either way works for me, I've tested without the effects and it's fine as well. This is more of a style thing, since executing directly in the render is basically an effect that runs every time. In terms of efficiency I'd say no effect is better, since we're just doing a single check as opposed to the multi checks involved in effect eval. But that's not something we should factor in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll follow the react guidelines on this one, and we'll go without the effects. Not particularly opinionated on this.

@github-actions github-actions bot temporarily deployed to demo-958-2-debounce-numberfiel January 23, 2024 05:16 Destroyed
Copy link
Contributor

@douglasbouttell-camunda douglasbouttell-camunda left a comment

Choose a reason for hiding this comment

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

Looks fine. Just need to see why the screenshots are different.

@Skaiir
Copy link
Contributor Author

Skaiir commented Jan 26, 2024

@douglasbouttell-camunda These are the cross-library screenshots and I'm not sure why but they always fail. Within form-js anyways Visual regression tests is the only thing we really rely on.

@Skaiir Skaiir merged commit 21884f8 into develop Jan 26, 2024
10 of 14 checks passed
@Skaiir Skaiir deleted the 958-2-debounce-numberfield branch January 26, 2024 09:25
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Jan 26, 2024
@vsgoulart
Copy link
Contributor

@douglasbouttell-camunda These are the cross-library screenshots and I'm not sure why but they always fail. Within form-js anyways Visual regression tests is the only thing we really rely on.

@douglasbouttell-camunda @Skaiir We have to update the screenshots on the Tasklist repo, but I'm waiting for the next release because we have some breaking changes on form-js ui

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debounce input fields in form-js-viewer
3 participants