Skip to content

Commit

Permalink
show input placeholder for default (zero) value
Browse files Browse the repository at this point in the history
  • Loading branch information
leprik committed Jun 19, 2023
1 parent dc27f6c commit 3470a39
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion includes/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public function register(): void {
[
'description' => __( 'MGID Widget ID', 'web-stories' ),
'type' => 'integer',
'default' => 0,
'default' => null,
'show_in_rest' => true,
]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export const TEXT = {
};

function MgidSettings({ widgetId: mgidWidgetId, handleUpdate }) {
// fix null error
mgidWidgetId = mgidWidgetId ?? '';

const [widgetId, setWidgetId] = useState(mgidWidgetId);
const [widgetIdInputError, setWidgetIdInputError] = useState('');
const canSaveWidgetId = widgetId !== mgidWidgetId && !widgetIdInputError;
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/integration/tests/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function test_on_plugin_uninstall(): void {
$this->assertSame( '', get_option( $this->instance::SETTING_NAME_AD_MANAGER_SLOT_ID ) );
$this->assertSame( '', get_option( $this->instance::SETTING_NAME_ADSENSE_PUBLISHER_ID ) );
$this->assertSame( '', get_option( $this->instance::SETTING_NAME_ADSENSE_SLOT_ID ) );
$this->assertSame( 0, get_option( $this->instance::SETTING_NAME_MGID_WIDGET_ID ) );
$this->assertSame( null, get_option( $this->instance::SETTING_NAME_MGID_WIDGET_ID ) );

Check failure on line 91 in tests/phpunit/integration/tests/Settings.php

View workflow job for this annotation

GitHub Actions / Lint

You should use assertNull() instead of assertSame(null, $actual).
$this->assertSame( [], get_option( $this->instance::SETTING_NAME_EXPERIMENTS ) );
$this->assertSame( 0, get_option( $this->instance::SETTING_NAME_ACTIVE_PUBLISHER_LOGO ) );
$this->assertSame( [], get_option( $this->instance::SETTING_NAME_PUBLISHER_LOGOS ) );
Expand Down

0 comments on commit 3470a39

Please sign in to comment.