Skip to content

Reactive blocks drawer hidden icon #7118

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

Draft
wants to merge 2 commits into
base: develop-minor
Choose a base branch
from

Conversation

afbora
Copy link
Member

@afbora afbora commented Apr 4, 2025

Fixes

Breaking changes

None

Docs

Ready?

  • In-code documentation (wherever needed)
  • Unit tests for fixed bug/feature
  • Tests and CI checks all pass

For review team

  • Add lab and/or sandbox examples (wherever helpful)
  • Add changes & docs to release notes draft in Notion

@afbora afbora added this to the 4.8.0 milestone Apr 4, 2025
@afbora afbora requested a review from a team April 4, 2025 13:46
@afbora afbora self-assigned this Apr 4, 2025
@afbora afbora linked an issue Apr 4, 2025 that may be closed by this pull request
],
methods: {
show() {
this.hidden = false;
Copy link
Member

Choose a reason for hiding this comment

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

Don't you get console errors with this? Usually Vue is strictly against directly mutating props.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, no 🤷‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not expert about that but I think you're right. I have updated as your idea anyway.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should update the drawer props instead:

this.$panel.drawer.props.hidden = false;

Copy link
Member Author

Choose a reason for hiding this comment

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

I think my last change that Nico's idea is better :)

Copy link
Member

Choose a reason for hiding this comment

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

@afbora I wouldn't create a new data entry. It introduces just another place this needs to be updated, another place that could be false later. Better to have a single place of truth (the prop).

@bastianallgeier I also don't think directly updating the drawer prop is the best idea. We should find out why emitting the event isn't working - or why it is working but the drawer props aren't reactively updating. I think that's the actual bug.

As I think about it, it's probably the same issue as #6301

Copy link
Member Author

Choose a reason for hiding this comment

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

@distantnative I looked into it a bit. The problem seemed simple but I guess it's more difficult than I expected. Feel free to close the PR

@afbora afbora marked this pull request as draft April 6, 2025 14:29
@afbora
Copy link
Member Author

afbora commented Apr 13, 2025

After digging into Vue’s reactivity system, I realized that props are one-way bindings. block.isHidden was already being updated correctly (set(block, "isHidden", false)), so the underlying data was never the issue. I think the problem is that the BlockDrawer component only received the initial value of block.isHidden as a plain prop, and since props are not reactive to changes in their original source unless explicitly watched, the component had no idea the value had changed.

So far IMHO this PR changes seems make sense :)

@afbora
Copy link
Member Author

afbora commented Apr 13, 2025

We can also add a watch to the hidden prop in BlockDrawer to make sure the local value updates if the parent changes it later.

watch: {
  hidden(value) {
    this.isHidden = value;
  }
}

@distantnative
Copy link
Member

distantnative commented Apr 13, 2025

Have you tried if that works?

My understanding is rather that Vue props indeed are reactive. But the problem is that we lose reactivity when opening a dialog or drawer down in State.set(). I've tried a few things but so far not found a way how to keep reactivity alive.

I really think it's the same problem as #6301

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

Successfully merging this pull request may close these issues.

Blocks drawer: hidden icon in drawer options not reactive
3 participants