Skip to content

Missing params on partial theme merge #253

@markov00

Description

@markov00

Describe the bug
I think we miss an important part on the mergePartial function. We actually relay on the fact that the default theme has all the property in place, and we are merging the partial theme on top of those properties. The problem comes when we want to merge in a property that is undefined on the default theme, like the dash array of a StrokeStyle. The merge should take all the elements from the default theme + all the element of the partial and merge them together.

To Reproduce
Steps to reproduce the behavior: add a test with the following code:

 test('should merge optional parameters', () => {
  interface OptionalTestType {
    value1: string;
    value2?: number;
    value3: string;
  }
  const defaultBase: OptionalTestType = {
    value1: 'foo',
    value3: 'bar',
  };
  const partial: RecursivePartial<OptionalTestType> = { value1: 'baz', value2: 10 };
  const merged = mergePartial(defaultBase, partial);
  expect(merged).toEqual({
    value1: 'baz',
    value2: 10,
    value3: 'bar',
  });
});

Expected behavior
Merging two object will results in a merge, not just on an object overwritten with the partial values.

Screenshots
n/a

Version (please complete the following information):

  • OS: all
  • Browser: all
  • Elastic Charts: 7.0.1

Additional context
n/a

Errors in browser console
n/a

Kibana Cross Issues
n/a

Checklist

  • every related Kibana issue is listed under Kibana Cross Issues list
  • kibana cross issue tag is associated to the issue if any kibana cross issue is present

Metadata

Metadata

Assignees

Labels

:stylingStyling related issuebugSomething isn't workingreleasedIssue released publicly

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions