Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reset button to Time control #323

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/control-date-time.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-components', 'wp-date', 'wp-hooks', 'wp-i18n'), 'version' => 'be897623eeab248f5aa8');
<?php return array('dependencies' => array('wp-components', 'wp-date', 'wp-hooks', 'wp-i18n'), 'version' => 'a8057b816ff1aca30047');
2 changes: 1 addition & 1 deletion build/control-date-time.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions controls/date_time/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ function DateTimePicker(props) {
resolvedFormat = settings.formats.time || 'g:i a';
}

// Reset.
const resetButtonLabel = __('Reset', 'lazy-blocks');

const formattedDate = value
? dateI18n(resolvedFormat, value, currentTimezone)
: buttonLabel;
Expand Down Expand Up @@ -159,6 +162,17 @@ function DateTimePicker(props) {
) : (
''
)}
<Button
size="small"
key={resetButtonLabel}
label={resetButtonLabel}
className={'is-tertiary'}
onClick={() => {
onChange?.(null);
}}
>
{resetButtonLabel}
</Button>
</div>
)}
/>
Expand Down
Loading