Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Documentation for renderLanguageSelect is inaccurate #95

Open
@dino115

Description

@dino115

Hi,
the documentation for a custom renderLanguageSelect describes the onChange method with a parameter for selectedValue.

onChange: (selectedValue: string) => void,

But as you can see in the code component, the onChange method requires an event handler. It calls preventDefault, stopPropagation and access the value through ev.currentTarget.value (line 44).

I have worked around this by calling onChange with a fake event with noops for the two methods and the newly selectedValue nested in currentTarget.value. So for now it is not a big problem, and maybe it helps other people to implement an own language selector which doesn't depends on a select input.

createChangeLanguageHandler: ({ onChange }) => newValue => {
  // call onChange with a fake event
  onChange({
    preventDefault: () => {},
    stopPropagation: () => {},
    currentTarget: { value: newValue },
  });
}

Please update the documentation or improve the onChange handler to work as described.

Keep up your good work! Cheers 🍻️

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions