Skip to content

[HxInputDate] [HxInputDateRange] Changing value causes two calls of EditContext.OnFieldChanged #787

@jirikanda

Description

@jirikanda

Reprosteps

  • Handle EditContext.OnFieldChanged event
  • Click on a date in the calendar.
  • EditContext.OnFieldChanged event handler is called twice

Why?

(both HxInputDate<TValue> and also HxInputDateInternal<TValue> inherit from InputBase<TValue>)

First call

  • HxInputDateInternal<TValue>.HandleValueChanged is called.
  • HxInputDateInternal<TValue>.HandleValueChanged sets the CurrentValueAsString.
  • CurrentValueAsString setter sets InputBase<TValuegt;.CurrentValue.
  • InputBase<TValue>.CurrentValue calls ValueChanged (important to understand the the second call)
  • The InputBase<TValue>.CurrentValue setter calls EditContext.NotifyFieldChanged for the first time.

Second call

  • HxInputDate<Value> handles ValueChanged event
  • It sets the CurrentValue property (see BuildRenderInputCore method, sequence number 101).
  • The InputBase<TValue>.CurrentValue setter calls (again) EditContext.NotifyFieldChanged.

Posible solutions (not sure right now)

  • only HxInputDate<TValue> should derive from InputBase<TValue>
  • OR HxInputDate<TValue> should not Set CurrentValue, but it should fire ValueChanged event

(I guess this occurs also in HxInputDateRange while it uses the same code structure.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions