Skip to content

Commit

Permalink
Add missing getTextLabel implementation for BaseDateTimeWidget, so th…
Browse files Browse the repository at this point in the history
…e value is displayed if it is available instead of a JavaScript 'null'. (wagtail#12162)

Fixes wagtail#12094
  • Loading branch information
vaughnd authored and gasman committed Jul 31, 2024
1 parent aadad14 commit 0dc233b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog
~~~~~~~~~~~~~~~~

* Redirect to the last viewed listing page after deleting form submissions (Matthias Brück)
* Provide `getTextLabel` method on date / time StreamField blocks (Vaughn Dickson)
* Docs: Upgrade Sphinx to 7.3 (Matt Westcott)
* Maintenance: Removed support for Python 3.8 (Matt Westcott)
* Maintenance: Drop pytz dependency in favour of `zoneinfo.available_timezones` (Sage Abdullah)
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@
* Romein van Buren
* Chris Shenton
* Nathanaël Jourdane
* Vaughn Dickson

## Translators

Expand Down
3 changes: 3 additions & 0 deletions client/src/entrypoints/admin/telepath/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,9 @@ class BaseDateTimeWidget extends Widget {
if (opts && opts.soft) return;
element.focus();
},
getTextLabel() {
return this.getValue() || '';
},
idForLabel: id,
};
widget.setState(initialState);
Expand Down
4 changes: 4 additions & 0 deletions client/src/entrypoints/admin/telepath/widgets.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -809,4 +809,8 @@ describe('telepath: wagtail.widgets.DateTimeInput', () => {
boundWidget.focus();
expect(document.activeElement).toBe(document.querySelector('input'));
});

test('getTextLabel() returns the text of entered value', () => {
expect(boundWidget.getTextLabel()).toBe('2021-01-19 11:59');
});
});
1 change: 1 addition & 0 deletions docs/releases/6.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ depth: 1
### Other features

* Redirect to the last viewed listing page after deleting form submissions (Matthias Brück)
* Provide `getTextLabel` method on date / time StreamField blocks (Vaughn Dickson)

### Bug fixes

Expand Down

0 comments on commit 0dc233b

Please sign in to comment.