Skip to content

isBackgroundChange() is false for changes triggered by other users #23979

@Legioth

Description

@Legioth

Description of the bug

EffectContext.isBackgroundChange returns false for changes that are triggered by another user.

Expected behavior

Expected that changes from another user would be marked as background changes.

Minimal reproducible example

@Route
public class MainView extends VerticalLayout {
    private static final SharedValueSignal<Boolean> signal = new SharedValueSignal<>(true);

    public MainView() {
        Span span = new Span();
        span.bindText(() -> signal.get().toString()).onChange(context -> {
            System.out.println("Background change: " + context.isBackgroundChange());
        });
        add(span);

        add(new Button("Toggle from UI",click -> {
            signal.update(x -> !x);
        }));
        
        add(new Button("Toggle from background thread",click -> {
            Thread.startVirtualThread(() -> signal.update(x -> !x));
        }));
    }
}
  1. Open the same UI in two separate browsers so that they use separate sessions
  2. Click the "Toggle from UI" button
  3. Notice that Background change: false is printed twice. Expected to get one case with true and another with false.

Note that the "Toggle from background thread" button works as expected - changes triggered in that way are reported as background changes for both users.

Versions

  • Vaadin / Flow version: Vaadin 25.1.0-rc2

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    🔖 Normal Priority (P2)

    Status

    🔎Iteration reviews

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions