Issue
When building the renderable array we should not be unsetting the `#theme` variable and we should not be making assumptions that `#markup` or the `#text` variables exist in the render array.
This leads to the following notice being thrown:
"Notice: Undefined index: #text in _addtocalendar_preprocess_field() (line 191 of [..]/addtocalendar/includes/addtocalendar.build.inc)"
This also leads to inconsistencies in where the add to calendar button is displayed (before or after). The following screenshot is 4 different date types of Date and Daterange fields with the same AddtoCalendar settings. As you can see the placement of the button is inconsistent"

Proposal:
We should be using `#suffix` variable in the render array to place the AddtoCalendar button after the date is rendered.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | addtocalendar-inconsitent_rendering-2878572-2.patch | 2.71 KB | chrissnyder |
| Selection_540.png | 25.65 KB | chrissnyder |
Comments
Comment #2
chrissnyderThe attached patch should correct this issue and the notices thrown by leveraging the `#suffix` variable in the render array.
Comment #3
chrissnyderComment #4
chrissnyderNote: The patches in this issue and #2878558: Notice thrown when not using a mulitvalued date field. overlap. So depending on which one gets applied first the other may have to be re-rolled.
Comment #5
gg24 commentedComment #6
gg24 commentedPatch works as intended. Issuing RTBC.
Thanks!
Comment #8
gg24 commentedFixing this issue to 8.x-2.x-dev branch!