Font awesome Vue icon flipping if code is moved










1














I have some navigation buttons with fontawesome icons. 'Previous' has a left facing arrow. 'Next' has a right facing arrow. When left in their original order everything works as expected. When I rearrange the buttons, the 'Prev' left arrow icon flips to be facing right.
I have tried using different icons (chevron-left/right) and I get the same behavior.



Is this normal behavior that I am not aware of, or a bug, or something else entirely?



Order 1 :



 <button v-if="showPrev()" class="col-md-2 mb-3 btn btn-outline-info" @click="prev()"><i class="icon-large fas fa-arrow-left"></i> PREV </button>
<!-- Spacer --><div v-else class="col-md-2"></div>

<button v-if="showSubmit()" class="col-md-2 mb-3 btn btn-success" @click="next()"> SUBMIT <i class="icon-large fas fa-check"></i></button>
<button v-else-if="showFinish()" class="col-md-2 mb-3 btn btn-outline-danger" @click="finish()"> FINISH <i class="icon-large fas fa-check"></i></button>
<!-- Spacer --><div v-else class="col-md-2"></div>

<button v-if="showNext()" class="col-md-2 mb-3 btn btn-outline-info" @click="next()"> NEXT <i class="icon-large fas fa-arrow-right"></i></button>
<!-- Spacer --><div v-else class="col-md-2"></div>


Output 1



Order 2 :



 <button v-if="showPrev()" class="col-md-2 mb-3 btn btn-outline-info" @click="prev()"><i class="icon-large fas fa-arrow-left"></i> PREV </button>
<!-- Spacer --><div v-else class="col-md-2"></div>

<button v-if="showNext()" class="col-md-2 mb-3 btn btn-outline-info" @click="next()"> NEXT <i class="icon-large fas fa-arrow-right"></i></button>
<!-- Spacer --><div v-else class="col-md-2"></div>

<button v-if="showSubmit()" class="col-md-2 mb-3 btn btn-success" @click="next()"> SUBMIT <i class="icon-large fas fa-check"></i></button>
<button v-else-if="showFinish()" class="col-md-2 mb-3 btn btn-outline-danger" @click="finish()"> FINISH <i class="icon-large fas fa-check"></i></button>
<!-- Spacer --><div v-else class="col-md-2"></div>


Output 2



MCVE attempt :
(Font-awesome icons aren't displaying in SO snippets making reproduction impossible. If I'm missing something, comment and I'll edit)






<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />

<div class="card p-0 mt-5">
<div class="row pt-3">
<div class="col-md-3"></div>

<button class="col-md-2 mb-3 btn btn-outline-info"><i class="icon-large fas fa-arrow-left"></i> PREV </button>

<button class="col-md-2 mb-3 btn btn-outline-info"> NEXT <i class="icon-large fas fa-arrow-right"></i></button>

<button class="col-md-2 mb-3 btn btn-success"> SUBMIT <i class="icon-large fas fa-check"></i></button>

<div class="col-md-3"></div>
</div>
</div>












share|improve this question























  • Not normal behavior, you might have some CSS changing the layout. Can you throw together a running sample that reproduces this issue? Can't debug with just images.
    – Sheng Slogar
    Nov 12 '18 at 18:29






  • 1




    I'll throw together an MCV tomorrow morning and edit the post.
    – Peter-M
    Nov 12 '18 at 18:37










  • I am having trouble getting any font-awesome icons to appear in SO Snippets at all, making the bug impossible to MCVE. I will keep trying and editing.
    – Peter-M
    Nov 13 '18 at 10:11
















1














I have some navigation buttons with fontawesome icons. 'Previous' has a left facing arrow. 'Next' has a right facing arrow. When left in their original order everything works as expected. When I rearrange the buttons, the 'Prev' left arrow icon flips to be facing right.
I have tried using different icons (chevron-left/right) and I get the same behavior.



Is this normal behavior that I am not aware of, or a bug, or something else entirely?



Order 1 :



 <button v-if="showPrev()" class="col-md-2 mb-3 btn btn-outline-info" @click="prev()"><i class="icon-large fas fa-arrow-left"></i> PREV </button>
<!-- Spacer --><div v-else class="col-md-2"></div>

<button v-if="showSubmit()" class="col-md-2 mb-3 btn btn-success" @click="next()"> SUBMIT <i class="icon-large fas fa-check"></i></button>
<button v-else-if="showFinish()" class="col-md-2 mb-3 btn btn-outline-danger" @click="finish()"> FINISH <i class="icon-large fas fa-check"></i></button>
<!-- Spacer --><div v-else class="col-md-2"></div>

<button v-if="showNext()" class="col-md-2 mb-3 btn btn-outline-info" @click="next()"> NEXT <i class="icon-large fas fa-arrow-right"></i></button>
<!-- Spacer --><div v-else class="col-md-2"></div>


Output 1



Order 2 :



 <button v-if="showPrev()" class="col-md-2 mb-3 btn btn-outline-info" @click="prev()"><i class="icon-large fas fa-arrow-left"></i> PREV </button>
<!-- Spacer --><div v-else class="col-md-2"></div>

<button v-if="showNext()" class="col-md-2 mb-3 btn btn-outline-info" @click="next()"> NEXT <i class="icon-large fas fa-arrow-right"></i></button>
<!-- Spacer --><div v-else class="col-md-2"></div>

<button v-if="showSubmit()" class="col-md-2 mb-3 btn btn-success" @click="next()"> SUBMIT <i class="icon-large fas fa-check"></i></button>
<button v-else-if="showFinish()" class="col-md-2 mb-3 btn btn-outline-danger" @click="finish()"> FINISH <i class="icon-large fas fa-check"></i></button>
<!-- Spacer --><div v-else class="col-md-2"></div>


Output 2



MCVE attempt :
(Font-awesome icons aren't displaying in SO snippets making reproduction impossible. If I'm missing something, comment and I'll edit)






<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />

<div class="card p-0 mt-5">
<div class="row pt-3">
<div class="col-md-3"></div>

<button class="col-md-2 mb-3 btn btn-outline-info"><i class="icon-large fas fa-arrow-left"></i> PREV </button>

<button class="col-md-2 mb-3 btn btn-outline-info"> NEXT <i class="icon-large fas fa-arrow-right"></i></button>

<button class="col-md-2 mb-3 btn btn-success"> SUBMIT <i class="icon-large fas fa-check"></i></button>

<div class="col-md-3"></div>
</div>
</div>












share|improve this question























  • Not normal behavior, you might have some CSS changing the layout. Can you throw together a running sample that reproduces this issue? Can't debug with just images.
    – Sheng Slogar
    Nov 12 '18 at 18:29






  • 1




    I'll throw together an MCV tomorrow morning and edit the post.
    – Peter-M
    Nov 12 '18 at 18:37










  • I am having trouble getting any font-awesome icons to appear in SO Snippets at all, making the bug impossible to MCVE. I will keep trying and editing.
    – Peter-M
    Nov 13 '18 at 10:11














1












1








1







I have some navigation buttons with fontawesome icons. 'Previous' has a left facing arrow. 'Next' has a right facing arrow. When left in their original order everything works as expected. When I rearrange the buttons, the 'Prev' left arrow icon flips to be facing right.
I have tried using different icons (chevron-left/right) and I get the same behavior.



Is this normal behavior that I am not aware of, or a bug, or something else entirely?



Order 1 :



 <button v-if="showPrev()" class="col-md-2 mb-3 btn btn-outline-info" @click="prev()"><i class="icon-large fas fa-arrow-left"></i> PREV </button>
<!-- Spacer --><div v-else class="col-md-2"></div>

<button v-if="showSubmit()" class="col-md-2 mb-3 btn btn-success" @click="next()"> SUBMIT <i class="icon-large fas fa-check"></i></button>
<button v-else-if="showFinish()" class="col-md-2 mb-3 btn btn-outline-danger" @click="finish()"> FINISH <i class="icon-large fas fa-check"></i></button>
<!-- Spacer --><div v-else class="col-md-2"></div>

<button v-if="showNext()" class="col-md-2 mb-3 btn btn-outline-info" @click="next()"> NEXT <i class="icon-large fas fa-arrow-right"></i></button>
<!-- Spacer --><div v-else class="col-md-2"></div>


Output 1



Order 2 :



 <button v-if="showPrev()" class="col-md-2 mb-3 btn btn-outline-info" @click="prev()"><i class="icon-large fas fa-arrow-left"></i> PREV </button>
<!-- Spacer --><div v-else class="col-md-2"></div>

<button v-if="showNext()" class="col-md-2 mb-3 btn btn-outline-info" @click="next()"> NEXT <i class="icon-large fas fa-arrow-right"></i></button>
<!-- Spacer --><div v-else class="col-md-2"></div>

<button v-if="showSubmit()" class="col-md-2 mb-3 btn btn-success" @click="next()"> SUBMIT <i class="icon-large fas fa-check"></i></button>
<button v-else-if="showFinish()" class="col-md-2 mb-3 btn btn-outline-danger" @click="finish()"> FINISH <i class="icon-large fas fa-check"></i></button>
<!-- Spacer --><div v-else class="col-md-2"></div>


Output 2



MCVE attempt :
(Font-awesome icons aren't displaying in SO snippets making reproduction impossible. If I'm missing something, comment and I'll edit)






<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />

<div class="card p-0 mt-5">
<div class="row pt-3">
<div class="col-md-3"></div>

<button class="col-md-2 mb-3 btn btn-outline-info"><i class="icon-large fas fa-arrow-left"></i> PREV </button>

<button class="col-md-2 mb-3 btn btn-outline-info"> NEXT <i class="icon-large fas fa-arrow-right"></i></button>

<button class="col-md-2 mb-3 btn btn-success"> SUBMIT <i class="icon-large fas fa-check"></i></button>

<div class="col-md-3"></div>
</div>
</div>












share|improve this question















I have some navigation buttons with fontawesome icons. 'Previous' has a left facing arrow. 'Next' has a right facing arrow. When left in their original order everything works as expected. When I rearrange the buttons, the 'Prev' left arrow icon flips to be facing right.
I have tried using different icons (chevron-left/right) and I get the same behavior.



Is this normal behavior that I am not aware of, or a bug, or something else entirely?



Order 1 :



 <button v-if="showPrev()" class="col-md-2 mb-3 btn btn-outline-info" @click="prev()"><i class="icon-large fas fa-arrow-left"></i> PREV </button>
<!-- Spacer --><div v-else class="col-md-2"></div>

<button v-if="showSubmit()" class="col-md-2 mb-3 btn btn-success" @click="next()"> SUBMIT <i class="icon-large fas fa-check"></i></button>
<button v-else-if="showFinish()" class="col-md-2 mb-3 btn btn-outline-danger" @click="finish()"> FINISH <i class="icon-large fas fa-check"></i></button>
<!-- Spacer --><div v-else class="col-md-2"></div>

<button v-if="showNext()" class="col-md-2 mb-3 btn btn-outline-info" @click="next()"> NEXT <i class="icon-large fas fa-arrow-right"></i></button>
<!-- Spacer --><div v-else class="col-md-2"></div>


Output 1



Order 2 :



 <button v-if="showPrev()" class="col-md-2 mb-3 btn btn-outline-info" @click="prev()"><i class="icon-large fas fa-arrow-left"></i> PREV </button>
<!-- Spacer --><div v-else class="col-md-2"></div>

<button v-if="showNext()" class="col-md-2 mb-3 btn btn-outline-info" @click="next()"> NEXT <i class="icon-large fas fa-arrow-right"></i></button>
<!-- Spacer --><div v-else class="col-md-2"></div>

<button v-if="showSubmit()" class="col-md-2 mb-3 btn btn-success" @click="next()"> SUBMIT <i class="icon-large fas fa-check"></i></button>
<button v-else-if="showFinish()" class="col-md-2 mb-3 btn btn-outline-danger" @click="finish()"> FINISH <i class="icon-large fas fa-check"></i></button>
<!-- Spacer --><div v-else class="col-md-2"></div>


Output 2



MCVE attempt :
(Font-awesome icons aren't displaying in SO snippets making reproduction impossible. If I'm missing something, comment and I'll edit)






<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />

<div class="card p-0 mt-5">
<div class="row pt-3">
<div class="col-md-3"></div>

<button class="col-md-2 mb-3 btn btn-outline-info"><i class="icon-large fas fa-arrow-left"></i> PREV </button>

<button class="col-md-2 mb-3 btn btn-outline-info"> NEXT <i class="icon-large fas fa-arrow-right"></i></button>

<button class="col-md-2 mb-3 btn btn-success"> SUBMIT <i class="icon-large fas fa-check"></i></button>

<div class="col-md-3"></div>
</div>
</div>








<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />

<div class="card p-0 mt-5">
<div class="row pt-3">
<div class="col-md-3"></div>

<button class="col-md-2 mb-3 btn btn-outline-info"><i class="icon-large fas fa-arrow-left"></i> PREV </button>

<button class="col-md-2 mb-3 btn btn-outline-info"> NEXT <i class="icon-large fas fa-arrow-right"></i></button>

<button class="col-md-2 mb-3 btn btn-success"> SUBMIT <i class="icon-large fas fa-check"></i></button>

<div class="col-md-3"></div>
</div>
</div>





<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />

<div class="card p-0 mt-5">
<div class="row pt-3">
<div class="col-md-3"></div>

<button class="col-md-2 mb-3 btn btn-outline-info"><i class="icon-large fas fa-arrow-left"></i> PREV </button>

<button class="col-md-2 mb-3 btn btn-outline-info"> NEXT <i class="icon-large fas fa-arrow-right"></i></button>

<button class="col-md-2 mb-3 btn btn-success"> SUBMIT <i class="icon-large fas fa-check"></i></button>

<div class="col-md-3"></div>
</div>
</div>






javascript html vuejs2 font-awesome






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 10:17

























asked Nov 12 '18 at 18:12









Peter-M

65




65











  • Not normal behavior, you might have some CSS changing the layout. Can you throw together a running sample that reproduces this issue? Can't debug with just images.
    – Sheng Slogar
    Nov 12 '18 at 18:29






  • 1




    I'll throw together an MCV tomorrow morning and edit the post.
    – Peter-M
    Nov 12 '18 at 18:37










  • I am having trouble getting any font-awesome icons to appear in SO Snippets at all, making the bug impossible to MCVE. I will keep trying and editing.
    – Peter-M
    Nov 13 '18 at 10:11

















  • Not normal behavior, you might have some CSS changing the layout. Can you throw together a running sample that reproduces this issue? Can't debug with just images.
    – Sheng Slogar
    Nov 12 '18 at 18:29






  • 1




    I'll throw together an MCV tomorrow morning and edit the post.
    – Peter-M
    Nov 12 '18 at 18:37










  • I am having trouble getting any font-awesome icons to appear in SO Snippets at all, making the bug impossible to MCVE. I will keep trying and editing.
    – Peter-M
    Nov 13 '18 at 10:11
















Not normal behavior, you might have some CSS changing the layout. Can you throw together a running sample that reproduces this issue? Can't debug with just images.
– Sheng Slogar
Nov 12 '18 at 18:29




Not normal behavior, you might have some CSS changing the layout. Can you throw together a running sample that reproduces this issue? Can't debug with just images.
– Sheng Slogar
Nov 12 '18 at 18:29




1




1




I'll throw together an MCV tomorrow morning and edit the post.
– Peter-M
Nov 12 '18 at 18:37




I'll throw together an MCV tomorrow morning and edit the post.
– Peter-M
Nov 12 '18 at 18:37












I am having trouble getting any font-awesome icons to appear in SO Snippets at all, making the bug impossible to MCVE. I will keep trying and editing.
– Peter-M
Nov 13 '18 at 10:11





I am having trouble getting any font-awesome icons to appear in SO Snippets at all, making the bug impossible to MCVE. I will keep trying and editing.
– Peter-M
Nov 13 '18 at 10:11













1 Answer
1






active

oldest

votes


















0














The problem is with the 'vue-if' statements. When a vue-if fails and the button is not displayed, the next button to be rendered is displaying the icon that wasn't displayed because of the vue-if.



Simply wrapping the button/icon combo in a div and performing the vue-if check there solves the problem.



 <div v-if="showPrev()" class="col-md-2 mb-3 ">
<button class="btn btn-lg btn-outline-info" @click="prev()"><i class="icon-large fas fa-arrow-left"></i> PREV </button>
</div>





share|improve this answer






















  • Glad you figured it out. Also, noticing you're using functions in your v-if statement. Generally bad practice, I'd recommend using computed properties or data. That way, you have built-in reactivity without doing anything extra.
    – Sheng Slogar
    Nov 13 '18 at 14:06







  • 1




    I was under the impression that the only difference between a computed property and a method in Vue was that a computed property was cached. The website you linked even states as such. The showX() methods are calculating whether or not an element should be shown based on rule patterns that change on the fly, making cached values irrelevant. Am I misunderstanding something?
    – Peter-M
    Nov 13 '18 at 14:59










  • No, you're correct, and I misguided you with that reactivity bit -- both a function and a computed prop will update reactively. The idea with computed properties is that you could have any amount of logic being done in your showNext method and use it in multiple places (say a loop) without doing any extra work. If you're just doing a simple if statement or something else and only ever calling it once, there will essentially be no difference, but functions are generally reserved for event handlers and doing things. Also makes code easier to follow imo.
    – Sheng Slogar
    Nov 13 '18 at 15:20










  • Just to be clear, you're not doing anything explicitly wrong, it's just a pattern I've found useful to follow. :) Also, see this reference.
    – Sheng Slogar
    Nov 13 '18 at 15:21







  • 1




    Ah I see. Thank you for you feedback though. I will keep this in mind in future as I am sure there are places in my codebase that could benefit from computed properties.
    – Peter-M
    Nov 13 '18 at 15:45










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267833%2ffont-awesome-vue-icon-flipping-if-code-is-moved%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














The problem is with the 'vue-if' statements. When a vue-if fails and the button is not displayed, the next button to be rendered is displaying the icon that wasn't displayed because of the vue-if.



Simply wrapping the button/icon combo in a div and performing the vue-if check there solves the problem.



 <div v-if="showPrev()" class="col-md-2 mb-3 ">
<button class="btn btn-lg btn-outline-info" @click="prev()"><i class="icon-large fas fa-arrow-left"></i> PREV </button>
</div>





share|improve this answer






















  • Glad you figured it out. Also, noticing you're using functions in your v-if statement. Generally bad practice, I'd recommend using computed properties or data. That way, you have built-in reactivity without doing anything extra.
    – Sheng Slogar
    Nov 13 '18 at 14:06







  • 1




    I was under the impression that the only difference between a computed property and a method in Vue was that a computed property was cached. The website you linked even states as such. The showX() methods are calculating whether or not an element should be shown based on rule patterns that change on the fly, making cached values irrelevant. Am I misunderstanding something?
    – Peter-M
    Nov 13 '18 at 14:59










  • No, you're correct, and I misguided you with that reactivity bit -- both a function and a computed prop will update reactively. The idea with computed properties is that you could have any amount of logic being done in your showNext method and use it in multiple places (say a loop) without doing any extra work. If you're just doing a simple if statement or something else and only ever calling it once, there will essentially be no difference, but functions are generally reserved for event handlers and doing things. Also makes code easier to follow imo.
    – Sheng Slogar
    Nov 13 '18 at 15:20










  • Just to be clear, you're not doing anything explicitly wrong, it's just a pattern I've found useful to follow. :) Also, see this reference.
    – Sheng Slogar
    Nov 13 '18 at 15:21







  • 1




    Ah I see. Thank you for you feedback though. I will keep this in mind in future as I am sure there are places in my codebase that could benefit from computed properties.
    – Peter-M
    Nov 13 '18 at 15:45















0














The problem is with the 'vue-if' statements. When a vue-if fails and the button is not displayed, the next button to be rendered is displaying the icon that wasn't displayed because of the vue-if.



Simply wrapping the button/icon combo in a div and performing the vue-if check there solves the problem.



 <div v-if="showPrev()" class="col-md-2 mb-3 ">
<button class="btn btn-lg btn-outline-info" @click="prev()"><i class="icon-large fas fa-arrow-left"></i> PREV </button>
</div>





share|improve this answer






















  • Glad you figured it out. Also, noticing you're using functions in your v-if statement. Generally bad practice, I'd recommend using computed properties or data. That way, you have built-in reactivity without doing anything extra.
    – Sheng Slogar
    Nov 13 '18 at 14:06







  • 1




    I was under the impression that the only difference between a computed property and a method in Vue was that a computed property was cached. The website you linked even states as such. The showX() methods are calculating whether or not an element should be shown based on rule patterns that change on the fly, making cached values irrelevant. Am I misunderstanding something?
    – Peter-M
    Nov 13 '18 at 14:59










  • No, you're correct, and I misguided you with that reactivity bit -- both a function and a computed prop will update reactively. The idea with computed properties is that you could have any amount of logic being done in your showNext method and use it in multiple places (say a loop) without doing any extra work. If you're just doing a simple if statement or something else and only ever calling it once, there will essentially be no difference, but functions are generally reserved for event handlers and doing things. Also makes code easier to follow imo.
    – Sheng Slogar
    Nov 13 '18 at 15:20










  • Just to be clear, you're not doing anything explicitly wrong, it's just a pattern I've found useful to follow. :) Also, see this reference.
    – Sheng Slogar
    Nov 13 '18 at 15:21







  • 1




    Ah I see. Thank you for you feedback though. I will keep this in mind in future as I am sure there are places in my codebase that could benefit from computed properties.
    – Peter-M
    Nov 13 '18 at 15:45













0












0








0






The problem is with the 'vue-if' statements. When a vue-if fails and the button is not displayed, the next button to be rendered is displaying the icon that wasn't displayed because of the vue-if.



Simply wrapping the button/icon combo in a div and performing the vue-if check there solves the problem.



 <div v-if="showPrev()" class="col-md-2 mb-3 ">
<button class="btn btn-lg btn-outline-info" @click="prev()"><i class="icon-large fas fa-arrow-left"></i> PREV </button>
</div>





share|improve this answer














The problem is with the 'vue-if' statements. When a vue-if fails and the button is not displayed, the next button to be rendered is displaying the icon that wasn't displayed because of the vue-if.



Simply wrapping the button/icon combo in a div and performing the vue-if check there solves the problem.



 <div v-if="showPrev()" class="col-md-2 mb-3 ">
<button class="btn btn-lg btn-outline-info" @click="prev()"><i class="icon-large fas fa-arrow-left"></i> PREV </button>
</div>






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 13 '18 at 14:54

























answered Nov 13 '18 at 12:42









Peter-M

65




65











  • Glad you figured it out. Also, noticing you're using functions in your v-if statement. Generally bad practice, I'd recommend using computed properties or data. That way, you have built-in reactivity without doing anything extra.
    – Sheng Slogar
    Nov 13 '18 at 14:06







  • 1




    I was under the impression that the only difference between a computed property and a method in Vue was that a computed property was cached. The website you linked even states as such. The showX() methods are calculating whether or not an element should be shown based on rule patterns that change on the fly, making cached values irrelevant. Am I misunderstanding something?
    – Peter-M
    Nov 13 '18 at 14:59










  • No, you're correct, and I misguided you with that reactivity bit -- both a function and a computed prop will update reactively. The idea with computed properties is that you could have any amount of logic being done in your showNext method and use it in multiple places (say a loop) without doing any extra work. If you're just doing a simple if statement or something else and only ever calling it once, there will essentially be no difference, but functions are generally reserved for event handlers and doing things. Also makes code easier to follow imo.
    – Sheng Slogar
    Nov 13 '18 at 15:20










  • Just to be clear, you're not doing anything explicitly wrong, it's just a pattern I've found useful to follow. :) Also, see this reference.
    – Sheng Slogar
    Nov 13 '18 at 15:21







  • 1




    Ah I see. Thank you for you feedback though. I will keep this in mind in future as I am sure there are places in my codebase that could benefit from computed properties.
    – Peter-M
    Nov 13 '18 at 15:45
















  • Glad you figured it out. Also, noticing you're using functions in your v-if statement. Generally bad practice, I'd recommend using computed properties or data. That way, you have built-in reactivity without doing anything extra.
    – Sheng Slogar
    Nov 13 '18 at 14:06







  • 1




    I was under the impression that the only difference between a computed property and a method in Vue was that a computed property was cached. The website you linked even states as such. The showX() methods are calculating whether or not an element should be shown based on rule patterns that change on the fly, making cached values irrelevant. Am I misunderstanding something?
    – Peter-M
    Nov 13 '18 at 14:59










  • No, you're correct, and I misguided you with that reactivity bit -- both a function and a computed prop will update reactively. The idea with computed properties is that you could have any amount of logic being done in your showNext method and use it in multiple places (say a loop) without doing any extra work. If you're just doing a simple if statement or something else and only ever calling it once, there will essentially be no difference, but functions are generally reserved for event handlers and doing things. Also makes code easier to follow imo.
    – Sheng Slogar
    Nov 13 '18 at 15:20










  • Just to be clear, you're not doing anything explicitly wrong, it's just a pattern I've found useful to follow. :) Also, see this reference.
    – Sheng Slogar
    Nov 13 '18 at 15:21







  • 1




    Ah I see. Thank you for you feedback though. I will keep this in mind in future as I am sure there are places in my codebase that could benefit from computed properties.
    – Peter-M
    Nov 13 '18 at 15:45















Glad you figured it out. Also, noticing you're using functions in your v-if statement. Generally bad practice, I'd recommend using computed properties or data. That way, you have built-in reactivity without doing anything extra.
– Sheng Slogar
Nov 13 '18 at 14:06





Glad you figured it out. Also, noticing you're using functions in your v-if statement. Generally bad practice, I'd recommend using computed properties or data. That way, you have built-in reactivity without doing anything extra.
– Sheng Slogar
Nov 13 '18 at 14:06





1




1




I was under the impression that the only difference between a computed property and a method in Vue was that a computed property was cached. The website you linked even states as such. The showX() methods are calculating whether or not an element should be shown based on rule patterns that change on the fly, making cached values irrelevant. Am I misunderstanding something?
– Peter-M
Nov 13 '18 at 14:59




I was under the impression that the only difference between a computed property and a method in Vue was that a computed property was cached. The website you linked even states as such. The showX() methods are calculating whether or not an element should be shown based on rule patterns that change on the fly, making cached values irrelevant. Am I misunderstanding something?
– Peter-M
Nov 13 '18 at 14:59












No, you're correct, and I misguided you with that reactivity bit -- both a function and a computed prop will update reactively. The idea with computed properties is that you could have any amount of logic being done in your showNext method and use it in multiple places (say a loop) without doing any extra work. If you're just doing a simple if statement or something else and only ever calling it once, there will essentially be no difference, but functions are generally reserved for event handlers and doing things. Also makes code easier to follow imo.
– Sheng Slogar
Nov 13 '18 at 15:20




No, you're correct, and I misguided you with that reactivity bit -- both a function and a computed prop will update reactively. The idea with computed properties is that you could have any amount of logic being done in your showNext method and use it in multiple places (say a loop) without doing any extra work. If you're just doing a simple if statement or something else and only ever calling it once, there will essentially be no difference, but functions are generally reserved for event handlers and doing things. Also makes code easier to follow imo.
– Sheng Slogar
Nov 13 '18 at 15:20












Just to be clear, you're not doing anything explicitly wrong, it's just a pattern I've found useful to follow. :) Also, see this reference.
– Sheng Slogar
Nov 13 '18 at 15:21





Just to be clear, you're not doing anything explicitly wrong, it's just a pattern I've found useful to follow. :) Also, see this reference.
– Sheng Slogar
Nov 13 '18 at 15:21





1




1




Ah I see. Thank you for you feedback though. I will keep this in mind in future as I am sure there are places in my codebase that could benefit from computed properties.
– Peter-M
Nov 13 '18 at 15:45




Ah I see. Thank you for you feedback though. I will keep this in mind in future as I am sure there are places in my codebase that could benefit from computed properties.
– Peter-M
Nov 13 '18 at 15:45

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267833%2ffont-awesome-vue-icon-flipping-if-code-is-moved%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto