Problem/Motivation
As it turned out in #2500525: Time ago/hence date/time formatting breaks caching; needs appropriate max age and #2686409: Time Ago summary does not render on Manage Display for Timestamp and Datetime fields the TimestampAgoFormatter formatter outputs a string that is very hard to cache. A time difference interval string changes very often making it uncacheable and then the whole page become uncacheable. The big problem here is that we return a string from the server that is refreshes very often. Using a max-age strategy works but it has the drawback of being very bad for the user experience.
Proposed resolution
- Use the default
TimestampFormatterformatter to show also a time difference formatted datesand deprecateEDIT: The deprecation is discussed in #2938705: Consider deprecating TimestampAgoFormatter.TimestampAgoFormatter - Add a new "Display as a time difference" option (as checkbox) in
TimestampFormattersettings. When this setting is On, a Javascript snippet replaces the current output of the formatter, which is a human readable formatted date/time, with a Display as a time difference string expression. Also the "Display as a time difference" settings will be visible and configurable. - The time difference replacement is formatted using a jQuery snippet that converts the actual PHP time difference functionality.
Pros of this solution:
- Assures a dynamic time difference that can be refreshed by JS with an interval that should be configured in the formatter.
- Is cacheable.
- Degrades nice to a normal formatted date/time for non-JS browsers.
Additional improvements:
- Use the
<time ...>HTML5 element. - Add a title (tooltip) to
<time ...>so that while displaying a time difference string, the user still can see the exact time by hovering with the mouse. The format of the tooltip should be configurable apart from the main date format because we may want a more detailed format than the main one. - Allow configuration of time difference string pattern as the actual
TimeAgoFormatterdoes.
Remaining tasks
Add tests.Add a post update script to fix configurations of existing entity view displays that are using theTimestampFormatter.Add update path test.Open a followup for the datetime.module corresponding formatter.
User interface changes
- For site builders: New options in TimestampFormatter settings.
- For users: "Time difference" dates will be up-to-date (no cached) and will refresh in the client browser on a specific interval.
API changes
Deprecated EDIT: Moved to #2938705: Consider deprecating TimestampAgoFormatter.TimestampAgoFormatter formatter.
Data model changes
New settings for TimestampFormatter formatter.
Manual testing
- Create a Timestamp field
- The formatter is set to "Default". Edit the formatter settings
- Check the "Display as time difference"
- Configure
- Set the refresh interval to a lower value so that you can observe later, in node view, how the field is refreshing
- Save the formatter settings.
- Check the formatter settings summary.
- Create a new node and save.
- See that the field correctly shows the field value as time difference.
- Hover with the mouse and check that a detailed time tooltip pops-up
- Without reloading the page, check that the field is refreshing client side after the refresh interval expires.
- Disable Javascript and reload the page.
- Check that the field degrades to a normal time representation.
Formatter settings form


Formatter settings summary

Javascript shows the timestamp as time difference

The time difference refreshes after the refresh interval expires

Javascript disabled degradation

Release notes snippet
In order to show the date/time as time difference (e.g. '2 hours 23 minutes ago') the timestamp default formatter exposes a setting "Display as a time difference". When enabled, the date/time is showed as time difference using Javascript, so the page remains cacheable. A refresh interval can be configured so that the time difference is refreshed without any page reload.
| Comment | File | Size | Author |
|---|
Issue fork drupal-2921810
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
claudiu.cristeaHere's a fist patch based on my experience in a project where I created a custom formatter, extending TimestampFormatter, for this purpose.
Unfortunately I don't have time to work on this. I just created this first approach just to open the party.
Comment #3
claudiu.cristea.
Comment #5
wim leersComment #6
claudiu.cristea.
Comment #7
droplet commentedmoment.js is too heavy. Since the timezone doesn't matter, I suggested making a custom one and yeah, to sync with PHP
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Datetime%...
Comment #8
claudiu.cristeaRemoving Moment.js as per #7.
Comment #10
claudiu.cristeaWrong schema.
Comment #12
claudiu.cristeaAdded upgrade path & test for upgrade path. Now, I'm looking into the failures.
Comment #13
claudiu.cristeaTemporary disabling the deprecation.
Comment #16
claudiu.cristeaComment #17
claudiu.cristeaComment #19
claudiu.cristeaComment #21
claudiu.cristeaAdded CR. Updating IS. Fixing the deprecation of plugin. Note that we don't have right now a plugin deprecation policy/mechanism. This is handled in #2922451: [policy no patch] Make it possible to mark plugins as deprecated.
Comment #23
claudiu.cristeaSeems that putting the deprecation error triggering in constructor, as it was suggested in #2922451-6: [policy no patch] Make it possible to mark plugins as deprecated, doesn't help too much. Moving into the main method.
Comment #24
claudiu.cristeaOops!
Comment #25
claudiu.cristeaThe deprecation of the plugin should wait for #2922451: [policy no patch] Make it possible to mark plugins as deprecated. Added only a @todo for now.
Comment #28
mpdonadioCan we pause this for a little bit to talk about the solution? Don't want to get too far down the road and then realize that we have problems.
I like the JS part, especially since it looks like it matches the current PHP behavior, and the time element part (see also #2793143: The datetime and daterange formatters (except plain) should use the HTML time element).
Few initial concerns.
Even if we deprecate the timeago formatter, I think we have a problem w/ non-JS uses. Besides non-JS browsers, formatters get used in other places (Views outputting something other than HTML, REST, etc). I don't think we can deprecate w/ plans to remove.
There would also be the issue of what to do with #2686409: Time Ago summary does not render on Manage Display for Timestamp and Datetime fields and the Datetime timeago formatter, which would have the same problem.
I'm wondering if instead of deprecating the timeago formatter and moving this functionality to the default formatter, we make this an option on the timeago formatter.
- Default behavior would be the current, with the cache quirk
- Optional JS-enhanced, cache friendly, version would be taken from this patch.
That would mean no deprecations, no non-JS problems, no update path, just an optional enhanced experience.
?
Comment #29
claudiu.cristea@mpdonadio, I'm not insisting for deprecation but next question comes into my mind: Why would a consumer (for REST or non-HTML views) get outdated data like a max-age cached 'time ago' interval? That has no value for a service consumer as it has no value for a user that reads a HTML in the browser. Deprecated doesn't mean it will not continue to work. The formatter will be available for the entire life cycle of Drupal 8.x. However, deprecating it will tell the consumers to update their client software and compute themselves the interval. But I agree that keeping timestamp_ago can be an option.
For the datetime.module equivalent we should open a followup blocked on this as I think that we can extend from this one. Also included also other bug fixes here and changing to
<time... >HTML5 as I need that for the JS part.Comment #30
claudiu.cristeaThis diff has been worked before #28 and is fixing usage of the formatter in Views where, there's now wrapper to store the settings. I'm holding the developement for a decision.
Comment #31
alexpott@claudiu.cristea you can't deprecate and then still have usages. That's not deprecating. The constructor deprecation would work but, for example, views.view.user_admin_people is still using the plugin so of course the deprecation message is firing.
Comment #32
claudiu.cristea@alexpott
You mean core usages? If yes, those should be replaced in this patch.
Comment #33
alexpottUnless you remove all usages in core then this is not deprecated - it is just hopeful. Perhaps to keep the issue smaller we should deal with the deprecation in a separate issue. Since that issue will need to add the @trigger_error, remove all the usages and add a legacy test.
Comment #34
alexpottWell then if you are really replacing all the usages then you should be able to add the @trigger_error() to the constructor but the patch in #30 is not. For example there are a few views which are using it:
And maybe other things too. This is the whole point of the @trigger_error() - to prove that the deprecation is real in core and also tell contrib / custom that in order to be ready for the future they need to change something too.
Comment #35
claudiu.cristea@alexpott, Got it, agree. While this patch is already ~40KB, I agree that the deprecation should go in a followup. However, there's no agreement yet on scope of this issue, see #28 and #29. I will touch this patch as soon as there will be an agreement on the direction this goes.
Comment #36
wim leersImpressive work!
Just a very high-level review. Definitely needs JS tests.
I think this can be done in a separate issue?
This seems like it could be
defer: true.😯 Woah, never seen this before!
Can you avoid renames and whitespace changes, to make this patch easier to review?
Can also be done in a separate issue.
Comment #37
claudiu.cristea@Wim Leers, thank you. Unfortunately without #36.1 and #36.5 there will be test failures. If I create new issues, I'll have to block this ticket.
#36.4: OK with the white lines but the renames are mandatory because right now the names are buggy.
Comment #38
claudiu.cristeaAdded the timestamp schema fix in a new issue, as @Wim Leers suggested in #36.1: #2931294: Timestamp field type misses schema for value.
Comment #40
claudiu.cristea#2931294: Timestamp field type misses schema for value is in. Let's continue here.
Moved the deprecation of
TimestampAgoFormatterin a followup #2938705: Consider deprecating TimestampAgoFormatter. @mpdonadio this allows us to unblock and move on with this ticket and postpone the decision whether to deprecate or not theTimestampAgoFormatterplugin. So let's push with this.Comment #41
claudiu.cristeaForgot to address #36.
Comment #44
joelpittet@claudiu.cristea I don't mind helping with the test issues to avoid adding
spaceless, ping me on IRC and I'll jump on that.Comment #45
claudiu.cristea@joelpittet, thank you. I'll contact you on IRC.
So, the failure is caused by #2938799: Provide the timestamp scalar data type. Postponing on that.
Comment #46
claudiu.cristea#2938799: Provide the timestamp scalar data type has been committed, re-activating this.
Comment #47
claudiu.cristeaThe singular is wrong: s/1 months/1 month. Fix it on the next iteration.
Comment #49
claudiu.cristeaThat was a random failure
Comment #50
claudiu.cristeaAdded refresh interval. Fixed #41.
Comment #51
jonathanshawExciting to see this coming along. Anything outstanding except #36.5 / #44?
Comment #52
joelpittetAddressing my comment in #44. If possible we try to avoid making markup changes to stable/classy.
Spaceless can be a potenially slow(because of the preg_replace) compile change, so we've avoided it:
vendor/twig/twig/lib/Twig/Node/Spaceless.php:29
We have a note here: https://www.drupal.org/node/1823416#whitespace in the caveat that suggest changing the test first. So that is what I did, by adding
trim()around the tests that already hadstrip_tags()added.And last, incase there is pushback, the alternative to spaceless is just add a twig comment after the tag. Like PHP, Twig will remove linebreaks after control statements and also comments.
Like this will work:
<time{{ attributes }}>{{ text }}</time>{# This comment removes the linebreak after. #}Comment #53
claudiu.cristeaWell, this is tricky. The refresh interval should be "smart" and should adapt after the timeago string is displayed for the first time. Let's take this example: The refresh interval is set to 15 sec. When the displayed value is something like
1 minute 17 secondseverything is OK but after some time when the time is showed as1 hour 24 minutes, refreshing every 15 seconds is a waste of CPU. As the time ago interval increases, the refresh interval should be adjusted to the minimum effort.Comment #54
jonathanshawYeah that is tricky. Perhaps the whole business of refreshing is best left to a follow-up.
The needed refresh interval depends on the date format, but we don't have easy way to understand that. A solution might be to try adding various time increments to the current time, 1 second, 1 minute, 1 hour, 1 day, 1 week, 1 month, 1 year. Then try to format these new times and see if they are different from the formatted current time. The first one to be different tells us what granularity we need to operate at.
The bigger pain is that the needed granularity changes. It might only be 1 second for the first 60 seconds, only 1 minute for the first hour etc. These possibilities can be handled in a similar way, but it's a bit complex and might need some javascript unit tests to ensure it's working.
Comment #55
droplet commentedWe could export it as a global helper `Drupal.showTimeAgo` and `detach` to cancel the updates (e.g. when the element is removed from DOM).
I also preferred a recursive setTimeOut.
IMO, 5 ~ 10 mins updates is more acceptable.
why base64?
** Needs to fix the ES6 code style.
Thanks!
Comment #56
claudiu.cristeaFixed #55.
Now the time is rendered (with JS) as:
Still to be fixed:
Drupal.dateFormatter.formatDiff()return, which now returns something like:Comment #57
claudiu.cristeaMore es6 code style.
Comment #58
jonathanshawI had same idea to use setTimeout not setInterval.
Now instead of
if we had something along the lines of
Could we set it up in such a way that unit test nextTimeAgoRefresh without having to worry about clock mocking?
Comment #59
claudiu.cristeaThis is fixing the refresh issue. Have no idea how this can be tested, except manually.
Comment #60
droplet commentedIt works I think:
(I have written in JS but should use PHPUnit instead. Or simply attach a JS test file)
If you take #1 away (broken code), "Update 2" will be failed.
Comment #61
claudiu.cristeaFixing docs.
@droplet, sorry I don't understand #60 :)
Comment #62
claudiu.cristeaThis is the first attempt to add a JS test. Unfortunately we have to block this on #2775653: JavascriptTests with webDriver because it seems that PhantomJS doesn't work with setTimeout() & Co. At least it didn't work on my local machine but it worked nice with Selenium.
Comment #63
droplet commentedI may miss some point here. Why 5 sec but not 3 or 4?
If we expecting that counting up from 1, 2, 3, 4, 5. Bingo! Then, I think the test failure rate will be high.
#60 is trying to catch 2 continue changes. Now, I think we able to simplify it by set 2 assertJsCondition to assign to the value. If both values are greater than previous, `Drupal.showTimeAgo` is working
Comment #64
joelpittet#2775653: JavascriptTests with webDriver is committed, unpostponing.
Comment #66
seanbThis patch seems to work fine! I think we need some more test coverage though. Here are some ideas.
Since the interval is 1 sec asserting the exact value doesn't seem to be a stable option. Maybe we could improve the asserts a bit:
Comment #67
askibinski commentedWe are using the (locked) core html_datetime pattern for creating a RFC 3339 compliant datetime, which breaks the JS in Safari on iOS/OSX because Safari expects a valid RFC3339 datetime.
Core uses the pattern 'Y-m-d\TH:i:sO' which is not valid RFC3339. It results in (for example) "2018-08-13T16:17:33+0200".
The RFC3339 standard describes the format with a required colon between the offset timezone hours:
"2018-08-13T16:17:33+02:00"
The PHP DateTime class also states that the pattern should be "Y-m-d\TH:i:sP" (using the "P" format character instead of "O", see reference).
At first I thought this might be a core issue but I think core is assuming ISO8601 for html_datetime. So instead I would suggest using a custom format 'Y-m-d\TH:i:sP' which seems to work with all browsers.
Comment #68
askibinski commentedHere is a new patch addressing the Safari issue explained #67.
Additional tests as mentioned in #66 by Sean still have to be written.
Comment #69
claudiu.cristea@askibinski, thank you. One question: Have you tested your patch in all major browsers?
Also, it would be nice to expand the comment just above the changed line to explain why we're not using the core
html_datetime(the explanation from #67, but more compacted, would be great).Comment #70
claudiu.cristeaComment #72
claudiu.cristeas/if/of
Comment #73
claudiu.cristeaAssigning for fixing the failures and trying to improve the testing.
Comment #74
claudiu.cristea\DateTime::RFC3339constant instead of a hardcoded format. Improved the docs.Looking now on how to improve the testing.
Comment #75
claudiu.cristeaOK, finally I managed to do a unit testing for the JS functions. I had to move a function outside but I'm sure it was worthy. I know that we don't have a unified way to unit test javascript but in this case, due to the implemented tests, I managed to catch few bugs. I'm still trying to find a way to test the UI, where now we have only an assertion.
Also this needs a change record.
Comment #76
claudiu.cristeaPHPCs & small docs fixes.
Comment #77
claudiu.cristeaYou're welcome to review :)
Comment #78
claudiu.cristeaThis formatter is used also in Views, so we need tests. Added tests for views and improved the entity view page test as it has been suggested in #63.
Comment #80
claudiu.cristeaFixed the test. The failure was because of this JS assertion that failed:
'10 seconds' > '9 seconds'. Now I'm extracting the numeric part and making the comparison as numeric values. Safer.I've created also the change notice https://www.drupal.org/node/2993639
Comment #81
claudiu.cristeaOuch, the patch :)
Comment #82
dawehnerI do have one conceptually question. I get how nice it is to refresh this, but I would have expected from reading the first bit of the issue summary, that this is something which could be moved into its own dedicated issue
You create this function dynamically once at least for every ```.each``` function. This could be moved to a more top level function right? This way it would need to be reassigned all the time.
On top of that the code would be a bit easier to understand
It would be super nice to give some examples in the summary of this function. I think this would massively make it easier to understand what is going on
I would have expected that core JS could use default values on options already
❓Is there a reason we don't use ```Array.prototype.forEach```?
Comment #83
jonathanshawAwesome work @claudiu.cristea. Most of these are nits or UX wordings, all are tentative suggestions.
Possibly 'Time difference'. The 'Options' seems unnecessary in the label and not consistent with tooltip.
Maybe 'Granularity of format' or 'Time units'?
Should the addition of this behavior and library be mentioned in the change record?
What is date_format used for if using timeago? Should we be hiding it?It seems strange having this above the timeago in the form; I think it should be below?This is problematic as help text because 'time ago' is not a phrase a normal person understands, and ago is specifically past. I'm also not sure we need to explain the no-JS fallback, and 'If checked' is a bit clumsy.
I suggest:
'Display as a time difference' and
"Show the difference in time between the timestamp and the current time, e.g. '6 months ago'."
Edit: I see now why we're mentioning JS/non-JS, it helps explain what the other time format settings are doing. I'm not sure what to propose, but overall the settings form is a little puzzling to the novice as it stands.
We should make our language consistent with the labels above. Maybe 'where you want the formatted time difference to appear'?
Would this be better as a select element, as it only has 7 possible values?
Maybe 'Time units' would help the layman more
This could use more explanation. Maybe 'How many time units will be used in formatting the time difference. For example, if '1' is selected then the displayed time difference will only contain a single time unit such as '2 years' or '5 minutes' never '2 years 3 months' or '5 minutes 8 seconds'.
Now that we have intelligent refreshing that dynamically adapts to the time interval, I'm not clear of the point of this setting.
In core we usually like to keep things simple and extensible rather than cater for every possibility.
A 60 second minimum refresh interval would seem to be safe for almost any browser even with a huge amount of fields on screen, and adequate for 99% of use cases.
It would be trivial for someone to extend this formatter and specify a faster refresh using the data-drupal-timeago attribute.
It's confusing labelling this as seconds and then having '1 minute' as the default option.
Perhaps 'How often (in seconds) to refresh the displayed time difference.
We're adding a lot of options here. Do we add everything to the summary or does that get too big at some point?
Also better 'Displayed as a time difference'.
Better 'Refresh every @interval'. And this doesn't handle the 'No refresh' option very well.
It shouldn't say configured as the value might not come from configuration in all use cases.
Does this respect really high refresh timeouts like 1000 seconds? Looks like it may bypass them and update times like "3 minutes" every minute.
Comment #84
claudiu.cristea@dawehner, @jonathanshaw, than you for your review:
#82.1: It was a discussion at some point but never a decision to postpone the refresh to a followup. And now the work is there and tested.
#82.2: Agree. Fixed.
#82.3: Below, inline with the code, I gave some examples but, right, let's add them also in the function docblock.
#82.4: Well... the reason is that I wanted to follow as much as I can the PHP version of this function
\Drupal\Core\Datetime\DateFormatter::formatDiff(). Also, I want to keep is as a generic function for JS.#82.5: I wasn't able to use
Array.prototype.forEach(). Probably because we're iterating over an object, not over an array? I have no idea.#831-3, 6-10, 12-15: Yes, that's a better wording. I review changed also the code/settings names to be consistent with the UI.
#83.14:
If 'No refresh', nothing is displayed, see the enclosing condition.
#83.16: I added a new test case for that and it seems that works correctly :)
#83.17: Changed the CR but still need to refer to the other formatter. That was the reason for this issue.
Updated the IS
Comment #85
jonathanshawChanging the machine & variable names to 'diff' not 'ago' seems like a good decision/
You didn't reply to #83.11 where I suggest removing the refresh setting from the formatter UI & config.
Some nits:
Is this comment quite accurate? The code doesn't seem to know or care how the time is currently formatted.
Should it be something more like 'Fills all time elements that have the data-drupal-timeago attribute with a refreshing time difference'?
'refresh interval' not 'configured refresh'
Should be 'refreshing more often'.
Comment #86
claudiu.cristea@jonathanshaw, thank you
True, I just forgot that. Here's my point: I don't think that we should hardcode the value to 60 sec. Even, probably, 60 sec would satisfy most of the cases I clearly see use cases for having different refresh intervals. I can imagine, for instance, an article that announces the opening of a store and on the page they are showing a dynamic time difference "We're opening in 2 days 2 hours 39 minutes 15 seconds" with the refresh interval set to 1 sec so that the visitor sees a dynamic countdown while he's visiting the page. And I can imagine a lot of other use-cases.
However, if for some UX reasons the settings form is looking too cluttered, I would still keep the setting but removed from the UI. Then, the value could be changed via config management, without needing to extend the class just for such a minor change. But I would not do that either.
#85.1: Agree but I had to find a more compact phrase in order to honour the coding standards.
#85.2,3: True. Fixed.
Comment #87
jonathanshaw#86 thanks for the reply - I think it's good to have it spelled out like this so others can decide.
I've worked on the CR, please check to see you think it's better and still accurate.
Comment #88
claudiu.cristea@jonathanshaw,
Wow, yes! It's a huge improvement and everything is now more clear. I'm sorry for the long list of wording and grammar issue, I'm not a native English speaker.
Comment #89
jonathanshawI created #2993811: Use the time-diff library in the datetime module's formatters as the needed follow-up. Looks like we need @mpdonadio to weigh in now.
Comment #90
claudiu.cristeaLet's assign, then.
@mpdonadio,
I removed the deprecation of
TimeAgoFormatterafter you raised your concerns in #28. There's a followup #2938705: Consider deprecating TimestampAgoFormatter, postponed on this , where we should decide if to deprecate or not. Anyway, now this issue is no more blocked. We need your review as subsystem maintainer.Comment #91
dawehnerIn that case you can use
Object.keys()|Object.values()... dependencies on the usecase.Comment #92
claudiu.cristea@dawehner, I need both.
Object.keys()is returning an array of keys, whileObject.values()an array of values. None fits.Comment #93
mpdonadioSincerely apologize for being away for so long. Life got in the way...
Reread the issue a few times and the latest patch.
I think essentially what we are saying is (restating the IS in my own words more for my own benefit)
- TimestampAgoFormatter, with the max-age stuff, works well for ago formats places where things can be old, but still want to update, like the "On Drupal.org ..." on our profiles.
- TimestampAgoFormatter, with the max-age stuff, works poorly for ago formats that change rather frequently, like the top of Twitter.
In other words, the max-age is good in theory, but in practice has big UX/DX impacts. So
- Let's output timestamps as proper HTML5 time elements regardless, with the correct attribute
- When outputting an ago format, add a JS ticker to update the display value of the HTML5 time element
- Defer TTL to the consumer
- Defer what to do with TimestampAgoFormatter and the datetime formatters to a followup
And we are also implying this is the better choice than adding a setting to TimestampAgoFormatter to output as a non-cached HTML5 time element w/ JS updater?
I think I am OK with this. Not passing the buck, but I think getting @jhedstrom to weigh in too, is a good idea. There is nothing technically wrong with this patch at a high level, if @jhedstrom thinks this is OK, too, we are just down to checking it for mistakes.
Comment #94
mpdonadioNM.
Comment #95
jhedstromI spent quite a bit of time reviewing the patch, and manually testing. I can't find anything to improve upon at this time, and it definitely works as expected. Allowing the time-ago format on fully-cacheable markup will be great, and even better when we get this in in the follow-up for the datetime formatters. This even has tests for the upgrade path, which is great!
Comment #97
jhedstromI'm not sure why the testbot is claiming the patch doesn't apply. I've applied to to the latest
8.7.xlocally with no problem.Comment #98
claudiu.cristea@jhedstrom, he's complaining about an old patch, from #62. Don't know why
Comment #99
alexpottThis appears to be untested.
If you used formatPlural() here and not t() then we'd be introducing less new translatable strings. Also this seems to be a lot of options. 10,15,30 - maybe we only need one of those? Or was there a reason for the chosen numbers - if so it should be documented.
Let's do the math here. There's no need for computers to do this everytime we load the JS it's not going to change.
This needs to use the \Drupal\Core\Config\Entity\ConfigEntityUpdater - see image_post_update_scale_and_crop_effect_add_anchor() for an example.
Can use instanceof here. I.e
if ($formatter_plugin instanceof TimestampFormatter::class) {Do we actually need to do this? Won't the entity view display self heal when you save it and add the default in?
Comment #100
claudiu.cristea@alexpott,
Actually, I think this check should be moved into
DateFormatter::format()so that a call such as:will always force the
$langcodeto 'en' when 'custom' and 'r'.Comment #101
wilfred waltman commentedRerolled patch #86 for Drupal 8.6.4
Comment #102
claudiu.cristea#99.1: As that is (should be) an implementation detail of
\Drupal::service('date.formatter')->format(), I'll split that into a new issue and will block this on that issue.#99.2: Fixed. From 10, 15, 30, I opted for 15 but I have no idea why. Can you be more specific?
#99.4, 5, 6: Fixed but note that
$entity_view_display->setComponent($name, $component);still cannot be avoided. That's the place where the component settings are self healing.Comment #103
claudiu.cristeaOk. I tried to see what's going on with #99.1. Suprize!
DateFormatter::format()always handles that correctly. I attached 2 Unit tests and one Kernel test to prove that. Anyway, reading the code, you can find this inDrupalDateTime::format(), line ~105:where it's obvious that the "r" date format marker is not encoded to be translated.
This closes also #99.1 making this issue RTBC if there are no other concerns.
Comment #104
claudiu.cristeaTypos...
Comment #107
claudiu.cristeaI should not have changed this line...
Comment #108
claudiu.cristeaNits.
Comment #109
jonathanshawComment #111
krzysztof domańskiUnrelated test failure. Back to RTBC.
#3035318: `DateFormatter()` assumes 30 days per month, while February only has 28 days. Causes fails in tests.
Comment #113
claudiu.cristeaIt was random failure.
Comment #116
claudiu.cristeaIt was a random failure, back to RTBC.
Comment #117
krzysztof domański2 of the last 16 tests (12,5%) ended with the same random failure.
https://www.drupal.org/pift-ci-job/1242425
25 Feb 2019: https://www.drupal.org/pift-ci-job/1211085
1 Mar 2019: https://www.drupal.org/pift-ci-job/1215415
This test
testTimestampFormatterWithTimeDiff()generates random test failures so I change to needs work.Comment #118
krzysztof domańskiI re-tested #108 to confirm the previous comment.
The test failed again https://www.drupal.org/pift-ci-job/1245779
Comment #119
claudiu.cristeaNot sure I got the failure correctly.
Comment #120
claudiu.cristeaDiscussed with @alexpott, at DrupalCon Seattle about the failure with PHP 5.5 & MySQL 5.5 and he told that this failure is not related to this issue and happens from time to time with the HEAD too. So, this could be safely RTBCed.
EDIT: The plan is to remove the support for PHP 5 starting with 8.8.x, so this failure will not be relevant anymore.
Comment #121
jhedstromI think the failures are all related to the switch to daylight savings that happens around this time of year for various regions. Moving back to RTBC.
Comment #122
krzysztof domański1. The default timezone for testing is Australia/Sydney (See
core/includes/install.core.inc). All previous random test failures were repeated on different days so I think they are not related to DST.25 Feb 2019: https://www.drupal.org/pift-ci-job/1211085
1 Mar 2019: https://www.drupal.org/pift-ci-job/1215415
30 Mar 2019 https://www.drupal.org/pift-ci-job/1245779
2. Here is a recent random failure probably related to the switch to daylight savings in Australia.
#3046570: \Drupal\Tests\datetime\Kernel\Views\FilterDateTest::testDateOffsets can fail during DST changes
3. Patch #108:
IMO this looks like time-sensitive random test failure.
New in Symfony 2.8: Clock mocking and time sensitive tests:
Comment #123
jonathanshawFor clock mocking see also #2986688: DrupalDateTime does not respect \Drupal::time() when interpreting strings as dates and https://www.drupal.org/project/datetime_testing
Comment #124
claudiu.cristea#122.3: That is already fixed in #119. The reason for the failure is that, on Drupal CI, in certain conditions, Selenium has some latency on updating the DOM. That latency might go beyond 1001 ms. With #119, that is fixed.
Comment #125
larowlannit: we could return after this and avoid the else
How confident are we this won't introduce random fails?
By my reckoning UnitTestCase already includes this - so not needed?
NW for last point
Comment #126
yogeshmpawarComment #127
yogeshmpawarAddressed comments #125 in updated patch & added an interdiff as well.
Comment #128
jonathanshaw#127 does not remove the "else" that was the purpose of #125.1
Comment #129
yogeshmpawarMade changes as per #128 & #125.1 & added an interdiff as well.
Comment #131
claudiu.cristeaIt seems that is missing
return refresh;after this block.Unused statement?
Responding also to #125.2: In #119, I ran few consecutive tests, also the patch is for 46 days in RTBC, so is tested daily. No failures.
Comment #132
yogeshmpawarComment #133
yogeshmpawarThanks @claudiu.cristea for review, Comments addressed in #131 & added an interdiff as well.
Comment #134
yogeshmpawarAdding 'else condition' again in code which was removed by me in #129 mistakenly.
Comment #135
claudiu.cristea#134, I think the removal of
else {...}was correct.Comment #136
claudiu.cristeaAs i told in #134, #133 is correct. Could you re-post that patch just to have the final work?
Comment #137
jonathanshawPatch from #133 reuploaded.
Comment #138
alexpottRerolled the patch - there was a simple conflict in
core/tests/Drupal/Tests/Core/Datetime/DateTest.phpdue to the getMock deprecation. I also fixed an es6 to js complication thing.I have not reviewed the patch properly yet.
Comment #139
idebr commentedClosed #3061755: Use time tag in TimestampFormatter as a duplicate issue.
Comment #140
catchI can't really understand what the description is suggesting here. Tagging for screenshots too.
Same issue.
Should this explicitly say it's for JavaScript refresh? Also do we really need this to be configurable per formatter - could it not be a sitewide thing controlled by settings?
Could we move this above the foreach, it looks a bit disjointed from everything else down here.
Like some other config entity updates, this should be done in a config save listener so that it also catches default configuration provided by modules and similar, and then the update can just load and save all entity view displays.
Comment #141
claudiu.cristea@catch
But the config save dispatcher is dispatching the event (
ConfigEvents::SAVE) after saving. There's no config pre-save event. Could you give a similar example?Comment #142
claudiu.cristea#140.1, 2: That was copied from
TimestampAgoFormatter. Hopefully, is much more clear now. However, as I'm not a native English speaker, maybe someone else could find a better description phrase. Added screenshot.#140. 3: Added explanation.
This was discussed already and we decided to go with a "per formatter" settings. See #86.
#140.4: Fixed
#140.5: I don't understand the requirement, as I commented in #141.
EDIT: I've been searched for all usages of
ConfigEvents::SAVEin core and none is updating the config when its schema is changing and it has to receive new config defaults.Comment #143
renguer0 commentedHi there. I'm testing lastest patch (#142). I've seen a difference when patching in :
My file shows getMock instead of createMock. I applied manual modifications to this file and all seems to be OK.
I really don't know can I apply this modifications to article comments views in my site and I'm using twig templates variables. Any tips?
BTW the label shows in the system and I using it for taxonomy terms and frontpage.
Thanks to all to colaborating with this.
Comment #144
chi commentedComment #145
chi commentedThe patch is not applicable to 8.8.x.
Comment #146
kostyashupenkoComment #148
claudiu.cristeaFinally I has a Slack discussion with @catch on #140.8. The suggestion is to use the presave hook and provide defaults for modules that are not providing them in the default configuration. See
system_entity_form_display_presave()andsystem_post_update_entity_reference_autocomplete_match_limit()for an example. About the "deprecated version" and "removed in" version, I;m quoting from chat:Now, this still needs UX review. How to proceed?
Comment #149
claudiu.cristeaIn the meantime the
corekeys has been removed from the view config entity, in #3087692: Remove the core key from views configuration..Comment #152
claudiu.cristeaIn the meantime Media module has added some tests using the timestamp formatter.
Comment #153
claudiu.cristeaAdded:
Comment #157
webchickWe went over this on today's UX meeting (https://youtu.be/0Fjk4cFiIV0 once it's finished processing).
First of all, big +1 to this feature. Seems like a nice performance improvement with minimal end user disruption.
For reference, the "before" version of the date/time formatter looks like this:
The proposed "after" version looks like this:
Which is... quite a bit more settings. ;)
The first question we had is whether or not we can handle this as new "Time ago/until" date format (as in something you'd configure at admin/config/regional/date-time). Because then, we would only need to put these settings in one place, globally, and would not need to worry about doing something like going out and changing something like "Time interval" from 1 minute to 15 minutes in 10 different places (one for each date/time field on our site). Instead, it would follow the existing pattern of formatters, which is to allow people to select from one of the predefined options that are found elsewhere. Then it could also presumably be used outside the Field API as well, for e.g. user created timestamps or what have you.
Failing that, using the #states API to hide all of the various other options until and unless "Display as a time difference" is selected would help a lot with the visual clutter here. If we go the checkbox route, one small improvement would also be moving the example to the checkbox label vs. the description as it was initially missed. "Display as a time difference (e.g. '6 months ago')" The other formats have the advantage of "previewing" the choice you're making in the selections themselves.
And then finally, there's nothing in the user interface at all that promotes this option as something that's important to do for performance. So it would be nice to add that to the field description in some way, to encourage people to make the selection.
It also doesn't look like there's any visual treatment that would show people that a "time ago" is something they can hover over to get a tooltip to get the actual date/time value. We should explore if Bartik has some pre-existing styles we can use for that (e.g. on Drupal.org we use a 1px dotted underline on these times), else maybe open a follow-up for that.
Comment #158
jonathanshaw#86 has some prior discussion about removing the 'Refresh interval' setting from the UI. Even if the format is moved to something configured globally, the refresh interval probably does NOT belong on that as the reaons for specifying it would depend on how rapidly the particular entity being displayed is likely to change.
Comment #159
claudiu.cristea@webchick & UX team, thank you for reviewing this patch. I was watching the video related to this review. Here are my notes:
The strings "@interval hence" & "@interval ago" are NOT date/time formats. They are translatable strings, thus we can't assimilate them with date/time formats. What we can probably do is to create a new config type that stores such strings plus the time units (int) and the refresh interval (int). Such a config entity is actually a preset for this formatter. Then in the formatter, the site builder just picks-up a preset. But what if the they want a custom config? The whole UI gets more complex and we have to handle a lot of cases (e.g. the preset changes, what happens with a specific formatter config?). Is it worth to bring such a complexity? And the new "preset config" needs also its admin UI, and so on... About the per-formatter refresh interval a discussion already took place in #83 & #86.
Yes, this is already implemented by I forgot to add a screenshot. I’ve uploaded now. I think this solves the case by offering a default sitewide preset.
I can see the value. Setting to "Needs work" to implement this.
There is the other formatter
timestamp_ago, which has problems with the cache and there's a question in #2938705: Consider deprecating TimestampAgoFormatter if it should be deprecated in favour of this solution. Wouldn't be better to add a there a short phrase indicating this option as better in terms of caching & performance?I will look into that but as far as i know is only d.o doing this. We've also using now the HTML5
<time />tag probably themes can select and apply such formats.Comment #160
claudiu.cristeaComment #161
dennis cohn commentedThe patch #152 failed to apply on 8.8.4
Comment #162
wilfred waltman commentedRerolled patch 152 for Drupal 8.8.4.
No changes to the code. Same code just on different lines.
Comment #164
seanbRerolled for 8.9.x. Setting to NR to run the tests.
Comment #165
nod_I didn't look at the PHP, here is the JS review:
Not necessary, if this file is the one that declare those 2 properties, no need to check if they exists.
Other scripts that needs to rely on this will need to add the library as a dependency.
can we use a data- attribute instead of a class please?
need to be scoped with the context too:
$(context).find()the each needs to be chained after the removeOnce, removeOnce act as a filter on "elements". since elements is a jquery object, it should be named "$elements".
shouldn't that be global to the script instead of having a version of "now" for each time element?
if it's an array, use array methods, jquery.each is unnecessary.
the name and parameters isn't coherent. I would expect 2 arguments: the diff value and options.
The comments should specify if it's a unix timestamp in seconds or miliseconds that is expected.
you can use Object.assign, instead of $.extend()
We might want to provide a way to change the format for this, beside the translation. I could see people wanting to have "1s" instead of "1 second".
Comment #167
seanbReroll for 9.1.x.
Comment #168
claudiu.cristea@nod_
Can we do this in a followup? This issue already includes a huge amount of work, the patch is almost 80K. If I create that configurable HERE, then we need config schema, we need UI. And if we need UI, then we need again usability review. This will never end and it's not the right way to manage such a big change. Can we followup, please?
Comment #169
nod_I'm ok with that
Comment #171
claudiu.cristeaI've created a MR. The 9.2.x development will continue there. The MR has been created from #150.
Comment #172
nod_added a few more comments on top of #165
Comment #173
claudiu.cristea#165.1, 2, 3: Fixed
#165.4: That will not gonna work. Every time it needs a fresh value.
#165.5: Is not working with
forEach(). The jQuery each() knows to break the iteration when returningfalseand that's a feature we need here.#165.6, 7: Fixed
#165.8: Will create a follow-up
Comment #174
claudiu.cristeaLatest changes:
I think I've covered all remarks with changes and some with explanations. This is ready for RTBC.
Comment #175
claudiu.cristeaIn 350f12, I've separated more clear
Drupal.timestampAsTimeDiffandDrupal.dateFormatter. Previously,Drupal.dateFormatterhad a dependency onDrupal.timestampAsTimeDiff. @nod_ & @droplet, do you think that it's worth it to have them in separate files, or even separate libraries (with dependency)?Comment #176
claudiu.cristeaOpened #3209371: False positive with array destructor for the https://www.drupal.org/pift-ci-job/2035225 PHP CS failure.
Comment #177
claudiu.cristeaComment #178
nod_Some comments about UI for sitebuilders and assumptions being broken between settings and code.
In short I think we might want to have a new formater to be able to make things clear for site builders (we can name it "Time Ago (dynamic)" or something to differentiate with the other, or rework the old one to be smarter maybe?). Maybe doing the inverse of what we did for the active class in menu links? (set with JS for auth users, set on the PHP side for anon users)
For the JS we call the library time-diff and there are 2 members declared on the Drupal object, put everything in
Drupal.timeDiffto limit confusion, as this is not a generic library (it needs settings and specific markup) I'm not sure it belongs to the misc folder (we're trying to avoid adding more stuff in there).Any reasons why it's not added to the date field type? Granularity will be days but it should still work for that one too because date also has a Time Ago formatter.
Comment #179
claudiu.cristeaIt's not about being smarter than the site builder. I want to still honour their choice but eliminate hidden refreshes that make no sense. Here are my remarks:
This discussion took place already, see the earlier comments. If we start again and again, this will never end. My point: creating a new formatter will add more confusion for site builders. Fixing this here and deprecating the other (see the follow-up) would be the logic path. Also we've already discussed in earlier comments about wording. We avoid "Time ago", we use "Time difference".
I would work to fix the other remarks but I'll not do it until these ^^^ two are clarified, otherwise it's just a waste of work on a complex new feature. Tagging with "Needs subsystem maintainer review" to get an opinion.
Also:
This is for the core
timestampfield type. We have a followup to add this todatetimefield too.Comment #180
nod_Thanks for the reply, not trying to reset the whole thing.
These are good points and it won't be such an issue with more accurate labels and descriptions. As is it is confusing and expectations/tradeoffs are not clear.
That would solve most of the issues I have with putting that in the same formatter
Comment #182
seanbA lot of nice work being done here! Here is an attempt to reroll the latest changes for 9.1.x.
Comment #183
seanbSorry, here is another attempt.
Comment #184
seanbAh, jQuery once has been removed from the patch for 9.2.x. That is going to be an issue. I guess for now 9.1.x user can technically use a reroll of #167 and upgrade to the 9.2.x patch later.
Comment #185
aaronmchaleDoes https://www.drupal.org/project/once help here?
Comment #186
seanbThanks! That could have fixed the issue as well. Good to know!
Comment #187
aaronmchaleYou're welcome :) According to the change logs, that library is now included in 9.2 and above, so if needed, this issue should be able to rely on that as a replacement for jQuery Once.
Comment #189
seanbReroll for 9.3.x.
Comment #190
seanbDoh, should have based the reroll on the MR instead of #184. Here is a reroll based on the MR for 9.3.x.
Comment #191
dwwThis would be fabulous! Very exciting. Hope to do a thorough review soon. Not exactly qualified to do a formal subsystem maintainer review for this, since I'm not formally a datetime maintainer (although I am a co-maintainer for datetime_extras), but I'll do what I can. 😉
Comment #192
catchThis is really a bug report, time ago formatting is broken with render caching.
Comment #193
ankithashettyRerolled the patch and fixed the custom command failure errors in #190, thanks!
Comment #195
ravi.shankar commentedTried to address failed tests.
Comment #196
claudiu.cristeaTrying to revive this issue as Drupal evolved a lot in one year
Comment #197
claudiu.cristeaNote on 390220c4:
In #140.5, @catch recommended to add an entity listener that would provide the new settings with their default values:
This has been done in #148.
However, while trying to add a test for the deprecation message, I found that the message is never triggered because, even a module's default configuration lacks the new settings, they are automatically added by the display entity on entity creation. See
EntityDisplayBase, specificallyEntityDisplayBase::init(). The method calls::setComponent()which ensures full configuration viaFormatterPluginManager::prepareConfiguration(). I removed that hook implementation as is never triggered.Comment #198
claudiu.cristea@nod_, regarding #180:
This is a nice idea. This I've implemented but only server side. Client side, I really don't know how can we change the field's label/description by using
#states. Or, is there a good example on how to achieve this with JS (adding new JS would make this huge MR even more complex: it needs JS code, libraries entry, tests, etc)With this I disagree. The new tooltip is designated also for normal timestamp format. You may have a very short format but with a more detailed format as tooltip.
I think this will only confuse the user. As I've explained, the adaptive refresh is transparent for the user. They will see the same thing regardless if the refresh is "smart" or not. It's only an optimization. I think the current label and description are pretty clear.
Comment #199
claudiu.cristeaDiscussed with @nod_ on Slack that we should add a description for the no-js case and avoid labels manipulation.
This is ready, IMHO
Comment #200
nod_Comment #201
claudiu.cristeaUpdated screenshots according to latest changes.
Comment #202
nod_Can't RTBC but it is for me
Comment #203
danflanagan8First, this is awesome. Thanks for all the nice work.
I made a couple comments on the MR related a problem when refresh is 0.
I have some more general musings on the default settings. The update hook works for entity view displays that are configured through Field UI. But it doesn't work for field blocks in Layout Builder that are using the TimestampFormatter. And I suspect it doesn't work for Views that are using the TimestampFormatter to render a field. This was initially worrying since the change record reads
But all the new settings have default values set in the formatter class, so I don't think the imperfect update is actually a problem. And I think the foreboding language can be removed from the CR. The code of the formatter is in reality quite forgiving and BC.
I also have questions about how the tooltip is implemented. Currently, if I'm using the timestamp formatter and I follow this upgrade path, my timestamp will get a tooltip by default. That seems strange because I didn't ask for the tooltip and the tooltip provides questionable value when the timestamp is not being displayed as an interval.
I would think the tooltip should either
1) be set to "No tooltip" by default
or
2) Keep the default settings but only use the tooltip is the timestamp is being rendered as an interval
Comment #204
nod_Fixed the refresh issue, thanks for the find :)
Comment #205
claudiu.cristea@danflanagan8, thank you for review. I think @nod_ and me, we've covered all your remarks:
Comment #206
danflanagan8@claudiu.cristea, looks awesome! My manual testing, including the new post_update hooks, went perfectly. The LB update doesn't work for overrides, but I don't know that there's any way to do that. In fact, the recent change to the image formatter that has similar update hooks (and caused one of the conflicts) doesn't even worry about LB at all. I think your LB post update is great.
The only comment I have now is that the new test method for testing a refresh of 0 needs to be reworked a bit. I left comments on the MR. Please let me know if any of my ramblings are not clear enough.
Thanks for all the awesome work on this one. Back to NW to update the new test.
Comment #207
claudiu.cristeaSome random failures on last commits but is green now. Fixed #206. Ready for review.
Comment #208
claudiu.cristeaGood to go!
Comment #209
danflanagan8I think everything is in order now. Thanks!
Comment #210
quietone commentedThis needs to be against 10.0.x now and have an MR for 9.5.x. Adding tag for a reroll.
Comment #211
claudiu.cristeaComment #212
danflanagan8Custom commands failed on that MR. I can't figure out what went wrong.
Comment #213
claudiu.cristea@danflanagan8, It seems that time-diff.es6.js needed re-compiling. Let's see
Comment #214
claudiu.cristea@danflanagan8, A fixture has been removed between D9 > 10. I see they've also changed the update tests location. As this has some code changes, could you, please, review?
Comment #215
danflanagan8Looks great! I'm going to RTBC even though the tests are still running; they have passed recently.
Comment #216
dwwFor the record, here's the bug I was trying to address with commit 0dc164ff : #3122231: Singular variant for plural string must contain @count. I agree for scope management it makes more sense to fix that separately, and update the docs for
formatPlural()accordingly. But I wasn't just making stuff up. 😉Thanks/sorry,
-Derek
Comment #217
spokjeMR doesn't apply any more since 8 Jun 2022 at 23:56 CEST.
Comment #219
andregp commentedMerge Request rebased.
Comment #220
claudiu.cristea@andregp, what kind of conflict resolution duplicates methods? https://git.drupalcode.org/project/drupal/-/merge_requests/570/diffs?com...
This is only a simple reroll. Back to RTBC
Comment #221
larowlanThere's a few unresolved threads here on the MR
Comment #222
larowlanThis will be 10.1.x only at this point as we're trying to avoid adding any new update hooks to 10.0 or 9.5 so the major update path is as risk free as possible.
But the good news is, it can go in to 10.1 pretty quickly
Comment #223
claudiu.cristeaOK, but it's the last time I'm touching this
EDIT: Because too often such complex issues/MRs are sent back for such minor nits that eventually can be fixed in followups.
Comment #224
danflanagan8@claudiu.cristea has addressed all the changes requested by @larowlan, so I'm going to throw this back to RTBC!
I want to note that the deprecation notice has in fact been removed entirely. The deprecation notice is not needed because there's not actually a breaking change of any kind here. The 'tooltip' and 'time_diff' settings have sensible default values and as such are not "mandatory" in that leaving them off will not result in any errors even if the update hooks are not managed correctly by the end user.
Thanks for your continued excellent work on this, @claudiu.cristea! This is a really nice feature that I am looking forward to using. :)
Comment #225
alexpottUnfortunately this issue is not mergeable at the moment. 10.1.x needs to be merged in and conflicts resolved.
Comment #226
alexpottAlso there's no .es6 files in D10 anymore and JS standards have changed because no IE.
Comment #227
danflanagan8The recent changes all look good to me. I had a little concern with the last commit, but after a back-and-forth with myself, I'm happy!
Comment #228
claudiu.cristeaComment #229
gambrySwapping the Drupal Global Contribution Weekend 2023 tag with the correct one.
Comment #230
lauriiiLeft some minor feedback on the MR
Comment #231
claudiu.cristea@lauriii, fixed your suggestion and answered the other 2 remarks. Setting back to RTBC.
Comment #232
catchLooks like @lauriii's last comment on the MR still needs to be resolved.
Comment #233
claudiu.cristeaI've only removed the class and, as this features already crossed RTBC several times, I dare to set it as RTBC.
Comment #234
claudiu.cristeaComment #235
chi commentedGiven that the rendered time is updated occasionally via JavaScript do we need to add
aria-liveattribute to it?Comment #236
claudiu.cristeaThis complex new feature is constantly moved back and forth with improvement requests that could be solved in followups. Could we, please, postpone this potential improvement to a followup? It becomes more and more expensive to keep this MR alive and aligned
Comment #237
rohan-sinha commentedReviewed the Patch on MR !570, worked for me.
Comment #238
rohan-sinha commentedConsidering #235 , checked the rendered time is updated occasionally via JavaScript, yes it needs accessibility work, will try to work on it.
Comment #239
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #240
jonathanshawI don't believe the bot, so I scheduled a retest
Comment #241
dww"Can not add test, MR is not mergeable"
Bot was right. A couple of merge conflicts in the rebase to today's 10.1.x branch. All of them in
core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.phpin thesettingsForm()method. Attached an example of one of the conflicts. I think I resolved it all properly, but I haven't tested. Let's see what the bot says now.Comment #242
claudiu.cristeaIt was just a reroll
Comment #243
catchGiven #235 and #236, I checked whether aria-live was an accessibility requirement here or not.
Docs at https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Liv...
Given this can potentially update very frequently, and it doesn't add new information to the page, it just silently updates information that's already there so that it's up-to-date if you leave a tab open for a long time or similar, I don't think we should add aria-live at all, if we did, we'd be setting it to aria-live="off" which is discouraged.
I am not really qualified to review the JavaScript in this issue, although to the extent that I can, I really like the approach of optimising the refresh to the maximum possible interval - that should hopefully make this cheap on people's tabs.
I did find one issue with the layout update path that needs fixing before this can go in - see comments on the MR. Marking needs work for that.
Comment #244
claudiu.cristeaComment #245
danflanagan8The new
layout_builder_entity_view_display_presavefunction as well as the updates tolayout_builder_post_update_timestamp_formatterlook like what was requested by @catch.I also like to change from
strpostostr_starts_with, which was a nice touch.Back to RTBC, hopefully for the last time. ;)
Comment #246
chi commentedRe #236 I think accessibility is not an improvement but something that needs to be done by default every time a new feature is delivered. I actually came to the same conclusion as #243. Just wanted someone with proper experience confirmed this.
Comment #248
catchThanks that looks better.
As mentioned I'm not qualified to sign off on the JS, but I checked who'd reviewed, and it's had extensive review from nod_ and droplet and others, so I think that's covered, and what I can review looked very good.
The PHP side looks great, it adds some extra form options, but if we didn't have them, I'd probably have asked for them, so I think it's good to have the flexibility those provide.
Did my best with the issue credits here but it's a very long issue with a lot of contributors, so apologies if I missed anyone.
Tagging for 10.1.0 release highlights.
Committed/pushed to 10.1.x, thanks!
I've also unpostponed the three spin-offs/follow-ups.
Comment #249
longwaveFixing tag
Comment #250
wim leers@claudiu.cristea opened this on 8 Nov 2017 at 12:06 CET and was the last person to touch the MR. Epic! 😄🚀
Comment #251
claudiu.cristea@catch,
I think @lauriii, @Chi and @Krzysztof Domański are missing. Crediting now.
Comment #253
heddnI've opened #3400522: time_diff 'description' field not propagated to existing core views, view tests or core schema after being added to TimestampFormatter that is encountered w/ use of these updates.
Comment #254
heddnRecording for my future self. Converting to use
#theme => timenow adds html markup to all views responses. That is mostly ok, until it isn't. Mainly with Views REST data exports read by React front-ends that don't know what do with the markup response when previously it was a raw ISO 8601 html_date.