From 9eb0a8a690fab78986c500bb971ac2665d727156 Mon Sep 17 00:00:00 2001 From: David Balderston Date: Fri, 18 Mar 2016 08:32:03 -0700 Subject: [PATCH] Remove Nav Item Placeholder and Set as Base Url Value Closes #6440 * Removed the `.fake-placeholder`class from the input, test, and css * On adding a nav item, if the url value has not been set by the user, then set it to the base url as shown in the input * If url has been set by the user, just do what it has always done --- .../client/app/components/gh-navitem-url-input.js | 5 ----- .../client/app/controllers/settings/navigation.js | 5 +++++ core/client/app/styles/layouts/settings.css | 4 ---- .../tests/acceptance/settings/navigation-test.js | 10 ---------- .../components/gh-navitem-url-input-test.js | 15 --------------- 5 files changed, 5 insertions(+), 34 deletions(-) diff --git a/core/client/app/components/gh-navitem-url-input.js b/core/client/app/components/gh-navitem-url-input.js index 97278bbcc4..b05198e10d 100644 --- a/core/client/app/components/gh-navitem-url-input.js +++ b/core/client/app/components/gh-navitem-url-input.js @@ -20,16 +20,11 @@ let isRelative = function (url) { export default TextField.extend({ classNames: 'gh-input', - classNameBindings: ['fakePlaceholder'], isBaseUrl: computed('baseUrl', 'value', function () { return this.get('baseUrl') === this.get('value'); }), - fakePlaceholder: computed('isBaseUrl', 'hasFocus', 'isNew', function () { - return this.get('isBaseUrl') && this.get('isNew') && !this.get('hasFocus'); - }), - didReceiveAttrs() { this._super(...arguments); diff --git a/core/client/app/controllers/settings/navigation.js b/core/client/app/controllers/settings/navigation.js index 4ba1256054..5eaabd1ab7 100644 --- a/core/client/app/controllers/settings/navigation.js +++ b/core/client/app/controllers/settings/navigation.js @@ -122,6 +122,11 @@ export default Controller.extend(SettingsSaveMixin, { addItem() { let newNavItem = this.get('newNavItem'); + // If the url sent through is blank (user never edited the url) + if (newNavItem.get('url') === '') { + newNavItem.set('url', '/'); + } + return newNavItem.validate().then(() => { this.addNewNavItem(); }); diff --git a/core/client/app/styles/layouts/settings.css b/core/client/app/styles/layouts/settings.css index ac031b5d10..f3911976a0 100644 --- a/core/client/app/styles/layouts/settings.css +++ b/core/client/app/styles/layouts/settings.css @@ -34,10 +34,6 @@ cursor: move; } -.gh-blognav-url .fake-placeholder { - color: #c1c1c1; -} - .gh-blognav-line { display: flex; width: 100%; diff --git a/core/client/tests/acceptance/settings/navigation-test.js b/core/client/tests/acceptance/settings/navigation-test.js index 1c9c774a92..5d34228238 100644 --- a/core/client/tests/acceptance/settings/navigation-test.js +++ b/core/client/tests/acceptance/settings/navigation-test.js @@ -150,11 +150,6 @@ describe('Acceptance: Settings - Navigation', function () { find('.gh-blognav-label:last .response').is(':visible'), 'blank label has validation error' ).to.be.true; - - expect( - find('.gh-blognav-url:last .response').is(':visible'), - 'blank url has validation error' - ).to.be.true; }); fillIn('.gh-blognav-label:last input', 'New'); @@ -165,11 +160,6 @@ describe('Acceptance: Settings - Navigation', function () { find('.gh-blognav-label:last .response').is(':visible'), 'label validation is visible after typing' ).to.be.false; - - expect( - find('.gh-blognav-url:last .response').is(':visible'), - 'blank url still has validation error' - ).to.be.true; }); fillIn('.gh-blognav-url:last input', '/new'); diff --git a/core/client/tests/integration/components/gh-navitem-url-input-test.js b/core/client/tests/integration/components/gh-navitem-url-input-test.js index e85de750c6..81a51a72e4 100644 --- a/core/client/tests/integration/components/gh-navitem-url-input-test.js +++ b/core/client/tests/integration/components/gh-navitem-url-input-test.js @@ -189,21 +189,6 @@ describeComponent( expect($input.val()).to.equal(`${currentUrl} /test`); }); - it('toggles .fake-placeholder on focus', function () { - this.set('isNew', true); - this.render(hbs ` - {{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}} - `); - let $input = this.$('input'); - - expect($input.hasClass('fake-placeholder')).to.be.true; - - run(() => { - $input.trigger('focus'); - }); - expect($input.hasClass('fake-placeholder')).to.be.false; - }); - it('triggers "change" action on blur', function () { let changeActionCallCount = 0; this.on('updateUrl', () => {