FEATURE: Highlight None option by default for bookmarks (#16949)

Since the default for the bookmark modal is to have no
reminder if you create a bookmark by clicking out of
the modal or pressing the Save button, this commit highlights
None by default.

Also changes the bookmark component to not use @on for Ember
lifecycle, we don't use that style
This commit is contained in:
Martin Brennan 2022-05-30 11:56:06 +10:00 committed by GitHub
parent 6ad6e1223d
commit 662c713347
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View File

@ -12,7 +12,7 @@ import {
import { action } from "@ember/object";
import { ajax } from "discourse/lib/ajax";
import bootbox from "bootbox";
import discourseComputed, { bind, on } from "discourse-common/utils/decorators";
import discourseComputed, { bind } from "discourse-common/utils/decorators";
import { formattedReminderTime } from "discourse/lib/bookmark";
import { and, notEmpty } from "@ember/object/computed";
import { popupAjaxError } from "discourse/lib/ajax-error";
@ -42,8 +42,9 @@ export default Component.extend({
model: null,
afterSave: null,
@on("init")
_setup() {
init() {
this._super(...arguments);
this.setProperties({
errorMessage: null,
selectedReminderType: TIME_SHORTCUT_TYPES.NONE,
@ -71,8 +72,9 @@ export default Component.extend({
this._loadPostLocalDates();
},
@on("didInsertElement")
_prepareUI() {
didInsertElement() {
this._super(...arguments);
later(() => {
if (this.site.isMobileDevice) {
document.getElementById("bookmark-name").blur();
@ -83,6 +85,8 @@ export default Component.extend({
// knows they have set these options previously.
if (this.model.id) {
this.set("showOptions", true);
} else {
document.getElementById("tap_tile_none").classList.add("active");
}
},

View File

@ -111,6 +111,10 @@ acceptance("Bookmarking", function (needs) {
exists("#bookmark-reminder-modal"),
"it shows the bookmark modal"
);
assert.ok(
exists("#tap_tile_none.active"),
"it highlights the None option by default"
);
});
test("Bookmarks modal selecting reminder type", async function (assert) {