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: Browser tab freezes, unresponsive, plus possible memory leak with form in modal (#4018) #4021

Merged
merged 6 commits into from
Mar 14, 2024

Conversation

kikuomax
Copy link
Collaborator

@kikuomax kikuomax commented Mar 9, 2024

Fixes #

Proposed Changes

  • Field makes sure that the contents of a new value for newMessage are different from the current newMessage before updating it to avoid infinite recursions that made a browser tab freeze
  • Add warnings of not mixing grouped and horizontal props of Field to the documentation

Remarks

Since Field was not designed to turn on grouped and horizontal props simultaneously, another issue will emerge after merging this PR, where once a validation error state is set, the error state won't be reset even after correcting the input. A workaround for now is not to mix grouped and horizontal. This PR will mitigate the worst scenario anyway.

- Fixes the bug that `Field` caused infinite recursions when both
  `grouped` and `horizontal` attributes were `true`, and a validation
  error was set. There were circular updates of the `newMessage` data
  field and the `message` prop of the child `Field`s. To break the loop,
  `watch` of the `message` prop makes sure that the contents of the new
  value are different from the `newMessage` data field before updating
  `newMessage`. Simple identity check won't work because `message`
  receives a brand new array every time.
- Adds new test cases that test `Field` with `grouped` and `horizontal`
  attributes `true`. The test would never stop due to infinite
  recursions if the previous fix were not applied.
- Adds the fix of `Field` freezing due to infinite recursions.
- Adds warnings of not mixing `grouped` and `horizontal` props of
  `Field`.
@kikuomax kikuomax requested a review from wesdevpro March 9, 2024 05:25
Copy link

netlify bot commented Mar 9, 2024

Deploy Preview for buefy-org ready!

Name Link
🔨 Latest commit 1fc3878
🔍 Latest deploy log https://app.netlify.com/sites/buefy-org/deploys/65efa7250315aa0008e56d90
😎 Deploy Preview https://deploy-preview-4021--buefy-org.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -69,7 +69,7 @@ export default [
},
{
name: '<code>horizontal</code>',
description: 'Group label and control on the same line for horizontal forms',
description: 'Group label and control on the same line for horizontal forms. Do not mix with <code>grouped</code>.',
Copy link
Member

Choose a reason for hiding this comment

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

Is there a more clear way to say this? And should we also explain, in a simple form, why we shouldn't mix them?

Copy link
Collaborator Author

@kikuomax kikuomax Mar 12, 2024

Choose a reason for hiding this comment

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

I briefly explained what will happen if we combine them. However, there would not be a reasonable explanation because it is a design flaw we have to address.

Copy link
Member

Choose a reason for hiding this comment

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

DM over discord. Maybe we could discuss this flaw over the weekend?

- Better explains the reason why `group` and `horizontal` props of
  `Field` should not be mixed.
- Explains the issue that remains after fixing the frozen Field bug.
@kikuomax kikuomax requested a review from wesdevpro March 12, 2024 01:20
@kikuomax kikuomax merged commit 76e8d43 into buefy:dev Mar 14, 2024
5 checks passed
@kikuomax kikuomax deleted the fix-frozen-field branch March 14, 2024 02:43
kikuomax added a commit to kikuomax/buefy that referenced this pull request Apr 2, 2024
…h form in modal (buefy#4018) (buefy#4021)

* fix(lib): infinite Field updates

- Fixes the bug that `Field` caused infinite recursions when both
  `grouped` and `horizontal` attributes were `true`, and a validation
  error was set. There were circular updates of the `newMessage` data
  field and the `message` prop of the child `Field`s. To break the loop,
  `watch` of the `message` prop makes sure that the contents of the new
  value are different from the `newMessage` data field before updating
  `newMessage`. Simple identity check won't work because `message`
  receives a brand new array every time.

* test(lib): add test cases for Field with grouped and horizontal

- Adds new test cases that test `Field` with `grouped` and `horizontal`
  attributes `true`. The test would never stop due to infinite
  recursions if the previous fix were not applied.

  Includes adaptation for @vue/test-utils V2:
  - `find(Component)` → `findComponent(Component)`
  - `findAll(Component)` → `findAllComponents(Component)`
  - `.at(i)` → `[i]` when accessing an item in `findAllComponents`
    results. @vue/test-utils V2 returns an ordinary array
  - `localVue` → `global: { components }`: @vue/test-utils V2 no longer
    supports `localVue`
  - `propsData` → `props`: `propsData` still works, but prepares for
    possible future deprecation

* docs(CHANGELOG): update unreleased log

- Adds the fix of `Field` freezing due to infinite recursions.
- Explains the issue that remains after fixing the frozen Field bug.

* chore(docs): add warning on grouped and horizontal (Field)

- Adds warnings of not mixing `grouped` and `horizontal` props of
  `Field`.
kikuomax added a commit to ntohq/buefy-next that referenced this pull request Apr 3, 2024
…h form in modal (buefy#4018) (buefy#4021)

* fix(lib): infinite Field updates

- Fixes the bug that `Field` caused infinite recursions when both
  `grouped` and `horizontal` attributes were `true`, and a validation
  error was set. There were circular updates of the `newMessage` data
  field and the `message` prop of the child `Field`s. To break the loop,
  `watch` of the `message` prop makes sure that the contents of the new
  value are different from the `newMessage` data field before updating
  `newMessage`. Simple identity check won't work because `message`
  receives a brand new array every time.

* test(lib): add test cases for Field with grouped and horizontal

- Adds new test cases that test `Field` with `grouped` and `horizontal`
  attributes `true`. The test would never stop due to infinite
  recursions if the previous fix were not applied.

  Includes adaptation for @vue/test-utils V2:
  - `find(Component)` → `findComponent(Component)`
  - `findAll(Component)` → `findAllComponents(Component)`
  - `.at(i)` → `[i]` when accessing an item in `findAllComponents`
    results. @vue/test-utils V2 returns an ordinary array
  - `localVue` → `global: { components }`: @vue/test-utils V2 no longer
    supports `localVue`
  - `propsData` → `props`: `propsData` still works, but prepares for
    possible future deprecation

* docs(CHANGELOG): update unreleased log

- Adds the fix of `Field` freezing due to infinite recursions.
- Explains the issue that remains after fixing the frozen Field bug.

* chore(docs): add warning on grouped and horizontal (Field)

- Adds warnings of not mixing `grouped` and `horizontal` props of
  `Field`.
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.

Browser tab freezes, unresponsive, plus possible memory leak with form in modal
2 participants