Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Update renderer innerHTML on each attach to work properly with @PreserveOnRefresh #128

Merged
merged 1 commit into from
May 7, 2019

Conversation

joheriks
Copy link

@joheriks joheriks commented May 6, 2019

When a route leads to a component annotated with @PreserveOnRefresh, all direct UI children (such as dialogs and notifications) are transferred to the new UI (see vaadin/flow#5608). This requires the dialog to update the renderer on attach.


This change is Reviewable

@CLAassistant
Copy link

CLAassistant commented May 6, 2019

CLA assistant check
All committers have signed the CLA.

@vaadin-bot
Copy link

SonarQube analysis reported 3 issues

Note: The following issues were found on lines that were not modified in the pull request. Because these issues can't be reported as line comments, they are summarized here:

  1. MINOR Dialog.java#L164: Move this constructor to comply with Java Code Conventions. rule
  2. MINOR Dialog.java#L411: Remove this method to simply inherit it. rule
  3. MINOR Dialog.java#L424: Remove this method to simply inherit it. rule

Copy link

@denis-anisimov denis-anisimov left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @denis-anisimov)


vaadin-dialog-flow/src/main/java/com/vaadin/flow/component/dialog/Dialog.java, line 67 at r1 (raw file):

getElement().getNode().addAttachListener(this::attachComponentRenderer);

The previous code allows to do it only once and you didn't have to care about several attach events.

Now you adding renderer in the attach listener.
And it's never removed.
It means that if dialog is reattached to the same UI then this code will be executed several times.

Is it safe ?

Copy link
Author

@joheriks joheriks left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @denis-anisimov)


vaadin-dialog-flow/src/main/java/com/vaadin/flow/component/dialog/Dialog.java, line 67 at r1 (raw file):

Previously, denis-anisimov (Denis) wrote…
getElement().getNode().addAttachListener(this::attachComponentRenderer);

The previous code allows to do it only once and you didn't have to care about several attach events.

Now you adding renderer in the attach listener.
And it's never removed.
It means that if dialog is reattached to the same UI then this code will be executed several times.

Is it safe ?

To my understanding, the method attachComponentRenderer doesn't actually add something, it only updates the innerHTML of the renderer and so, for the same UI, should be an idempotent operation.

Copy link

@denis-anisimov denis-anisimov left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved


vaadin-dialog-flow/src/main/java/com/vaadin/flow/component/dialog/Dialog.java, line 67 at r1 (raw file):

Previously, joheriks (Johannes Eriksson) wrote…

To my understanding, the method attachComponentRenderer doesn't actually add something, it only updates the innerHTML of the renderer and so, for the same UI, should be an idempotent operation.

True.

Copy link

@denis-anisimov denis-anisimov left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

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

Successfully merging this pull request may close these issues.

5 participants