Skip to content

JS error for Select option with number value #805

@grappler

Description

@grappler

When using these two configurations I get an JS error in the console: Uncaught TypeError: data.value.split is not a function

[
	'label'   => esc_html__( 'Zoom', 'static-map' ),
	'attr'    => 'zoom',
	'type'    => 'select',
	'options' => range( 1, 22 ),
],
[
	'label'   => esc_html__( 'Zoom', 'static-map' ),
	'attr'    => 'zoom',
	'type'    => 'select',
	'options' => array_combine( range( 0, 22 ), range( 0, 22 ) ),
],

The reason for this is that the data.value has a typeof number instead of string in these cases.

If I change the code to the following it works fine.

[
	'label'   => esc_html__( 'Zoom', 'static-map' ),
	'attr'    => 'zoom',
	'type'    => 'select',
	'options' => array_combine( range( 1, 22 ), range( 1, 22 ) ),
],

Related change #745

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