Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Cache panel contents after first load #105

Merged
merged 1 commit into from
May 27, 2019

Conversation

openorclose
Copy link

@openorclose openorclose commented May 21, 2019

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [x] Enhancement to an existing feature

What is the rationale for this request?

Content in panels are rerendered on each open, causing the above mentioned issues.

What changes did you make? (Give an overview)

Cache the rendered content on first load, then reuse it thereafter.

Provide some example code that this change will affect:

<panel header = "inner"><panel header = "inner"><panel header = "inner">
innermost
</panel></panel></panel>

Should now remember its nested state upon reopening of outermost panel.

Testing instructions:

Test that content is not recreated (e.g. input elements maintain their text) every time a panel is toggled open.

@openorclose openorclose force-pushed the cache-panels branch 2 times, most recently from 1854861 to 38ccc5f Compare May 22, 2019 04:27
@openorclose
Copy link
Author

Forced push.

Now that v-show is always used to show/hide panels, the v-else template is not used anymore and can be deleted.

@openorclose openorclose force-pushed the cache-panels branch 2 times, most recently from 57c2ea5 to 3a0a681 Compare May 22, 2019 06:02
@openorclose
Copy link
Author

Force pushed small bug fix.

isCached was wrongly set to true even when localExpanded was changed from false to false in created().

Panels that do not have the preload attribute
have their contents destroyed and recreated on each reopen.

This causes issues such as inner text inputs and inner panels not
remembering their previous state,
and panels with src attribute repeating the same ajax request.

See
MarkBind/markbind#868
MarkBind/markbind#483

Let's have an additional `isCached` property, which is set to true
whenever the content is/will be loaded. Only when isCached is true
will the content be rendered and.

As a side effect, since once the panel is loaded v-show is always used,
the v-else part of the template is not needed anymore,
which also reduces code duplication.
Copy link

@Chng-Zhi-Xuan Chng-Zhi-Xuan left a comment

Choose a reason for hiding this comment

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

LGTM after last commit message change.

@Chng-Zhi-Xuan Chng-Zhi-Xuan merged commit 282556d into MarkBind:master May 27, 2019
@Chng-Zhi-Xuan Chng-Zhi-Xuan added this to the v2.0.1-markbind.27 milestone Jun 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants