Skip to content

fix(fast-element1): fix design token updates when attaching/detaching nodes and deleting values #6960

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

Conversation

m-akinc
Copy link
Contributor

@m-akinc m-akinc commented May 14, 2024

Pull Request

📖 Description

This PR addresses a couple design-token-related bugs:

  1. Removing/adding a child element does not update the CSS token reflection of that child. E.g.
    • Starting with:
    <my-parent>
       <my-child></my-child>
    </my-parent>
    <my-other-parent></my-other-parent>
    • Define a token T (with CSS variable --T)
    • Explicitly set T to "10" for both <my-child> and <my-parent>
      • because <my-child>'s value is the same as the inherited value, the value is not reflected to CSS on <my-child>
    • Explicitly set T to "20" for <my-other-parent>
    • Reparent <my-child> under <my-other-parent> (detach, then append)
    • Because the value "10" is explicitly set on <my-child>, the value of the CSS variable --T should be "10" for it, but it is not. It is "20", which is incorrect.
      • since the value for <my-child> differs from <my-other-parent>, it should reflect the value to CSS. It doesn't. ❌
  2. Deleting a token value from an element should notify affected elements (and update CSS reflection). E.g.
    • Starting with: <my-element></my-element>
    • Define a token T (with CSS variable --T)
    • Explicitly set T to "10" for <my-element>
    • Delete T from <my-element>
    • <my-element> should not have any value for --T, but it is still defined as "10".

Also:

  • Removed .only from a combobox test that was apparently submitted on accident
  • Now catching errors thrown from derived token evaluation (and logging via console.error). Now that we are properly triggering token re-evaluations when detaching elements from the DOM, a derived token may throw an error during evaluation, because it depended on an inherited token value. It seems better to print an error than to let this derail execution.

🎫 Issues

N/A

👩‍💻 Reviewer Notes

Stackblitz demo of bug numbered 1 in description.
Stackblitz demo of bug numbered 2 in description.

📑 Test Plan

Added additional test cases.

✅ Checklist

General

  • I have included a change request file using $ yarn change
  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

@m-akinc
Copy link
Contributor Author

m-akinc commented May 28, 2024

@chrisdholt No rush, but it's been a couple weeks since I posted this, so I thought I'd give you a ping.

@m-akinc
Copy link
Contributor Author

m-akinc commented Jun 5, 2024

@janechu is there anything I can do to help get this in?

@janechu
Copy link
Collaborator

janechu commented Jun 5, 2024

@janechu is there anything I can do to help get this in?

LGTM, sorry for the delay!

@m-akinc
Copy link
Contributor Author

m-akinc commented Jun 7, 2024

@chrisdholt while we've got some momentum, would be nice to get a review on this. 😊

@m-akinc
Copy link
Contributor Author

m-akinc commented Jun 20, 2024

@janechu are you comfortable merging this in? @chrisdholt do you want to review?

@m-akinc
Copy link
Contributor Author

m-akinc commented Jul 30, 2024

@chrisdholt I'm still holding on to hope that this will be merged at some point. Should be a nice bug fix for production clients.

@m-akinc
Copy link
Contributor Author

m-akinc commented Sep 10, 2024

@chrisdholt @janechu Is the policy now not to take further changes into the archive branch? I don't want to keep pinging you all if it's pointless, but we are still relying on this branch and would like to be able to apply fixes if possible. We actually just identified a memory leak last week related to some design token bindings not getting cleaned up. Ideally, we would put up a PR for that as well.

@janechu janechu merged commit 913c27e into microsoft:archives/fast-element-1 Sep 11, 2024
5 checks passed
@janechu
Copy link
Collaborator

janechu commented Sep 11, 2024

@m-akinc going forward we won't be accepting new changes to archived branches, but we are in process of cleaning up the current outstanding PRs, doing a final publish, then the guidance will be new changes should get applied only to the current version. Sorry about the delay!

@m-akinc
Copy link
Contributor Author

m-akinc commented Sep 11, 2024

Thanks for clarifying, and thanks for merging.

@rajsite rajsite mentioned this pull request Nov 5, 2024
1 task
rajsite added a commit to ni/nimble that referenced this pull request Nov 5, 2024
# Pull Request

## 🤨 Rationale

Update FAST versions to include the following fixes:
- microsoft/fast#7022
- microsoft/fast#6960

And handle the following NI issues:
- Fixes #1661
- https://ni.visualstudio.com/DevCentral/_workitems/edit/2843309

## 👩‍💻 Implementation

Updates the Fast Foundation version. A test performance regression was
found in all browsers but particularly in Firefox, however [after
investigation by @m-akinc](#2456) it
was found to be an acceptable change. Fixes
#2456

## 🧪 Testing

Extensive testing done in #2456

## ✅ Checklist

- [x] I have updated the project documentation to reflect my changes or
determined no changes are needed.

---------

Co-authored-by: Mert Akinc <[email protected]>
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.

3 participants