-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #5701: Alert user to save changes before publishing #5948
Conversation
Hi @tjiang11, PTAL! |
Hi @ankita240796, Thanks for the PR! @nithusha21, can you please review this PR as I'm not sure about the expected behaviour for the issue #5701. |
Hi @ankita240796 Thanks for the PR. I am a little unsure myself about why this issue was filed. I think the issue was probably clicking a greyed out publish button, which was actually not clickable. In which case I think your fix is good. However, I would suggest changing the error message to also include some context regarding open warnings that are not yet resolved. So if the creator saves the draft, and still there are open warnings, the publish button will still be disabled, and the pop-up still asks me to save draft (which I cannot anymore). Probably, a better UX would be to have separate messages for either situation. So the current message is shown only when there are no open warnings and the draft isn't saved. Else, if there are warnings, we should show a message saying that. What do you think of this? |
Hi @nithusha21, I totally agree with your suggestion. It would be better to show the relevant error message to the user as per the situation. I will make the changes for the same. |
Hi @nithusha21, I have made the changes, PTAL! |
Hi all, I don't have enough context to comment usefully on the whole PR, but one thing I wanted to mention is that we never use in-built alert boxes -- they don't look great. Modals are the way to go here, as per other similar user interactions in Oppia. Thanks! |
Hi Sean, thanks for those inputs! Yeah, I would agree with Sean. @ankita240796 could you make these alerts into Modals? You could search for uibModal in the codebase to get examples of how to create a modal. Let me know if you need help! |
Yeah, I too agree with Sean. We have never used in-built alerts. Let us know if you need any help. More than happy to help :) |
Hi @nithusha21 @seanlip @bansalnitish , Would it be better if instead of creating a modal we just try to display the tooltip when the button is clicked? |
Hi @nithusha21 @seanlip @bansalnitish I have created a info modal to show the warning message to user if publish button is clicked without saving the drafts or resolving the warnings. Here is a screenshot for the case when draft is not saved: Do let me know if this looks fine or should we try displaying the tooltip on click. Also, would it be better if we provide an option to save draft in the info modal itself? Thanks! |
Hi @ankita240796 I think the modal looks great! Also I like the idea you have to add a button to save changes. One suggestion I have is to drop the ? and change the title to "Cannot publish changes.". Also, If we are doing this, do we want to continue to have the publish button greyed out in this situation? I am not entirely sure. Any suggestions @bansalnitish, @DubeySandeep, @aks681? |
I think a grey button explains the button is disabled If it's disabled we should not allow them to be clickable (we can use this cursor instead of hand-cursor), in that case, we should use a tooltip. If we are going to use modal then we should enable th Publish button. Again, we use grey color "save draft" button when there is nothing to save, What are we going to do here for a consistent UI behaviour in both buttons? Re "add a button to save changes.": |
Hi @nithusha21 @DubeySandeep I tried out some of the stuff discussed in the comments above and have also pushed the code for the same. PTAL, I will change the code according to your inputs on this. I also think that the publish button should not be greyed out if we are using a modal. |
I agree with @DubeySandeep that the save draft and publish should be consistent. Also I think modals here look a bit unecessary, tooltip is a good way to display a simple message (the reason why its not working) like during publish we have the tooltip Any suggestions @DubeySandeep, @nithusha21, @ankita240796 ? |
I think I agree with @bansalnitish that a modal here would be too complex. It would be better to use a tooltip. |
Hi @ankita240796, Sorry about the confusion on this PR! This is one of those issues for which we have no "correct" solution. There are many possibilities as outlined above. Could you write these down in a doc, and compare the pros and cons of these various choices? That way we will know what would be the best alternative to take. Otherwise, I think every time you try something new, one of us will have a different solution, and we will not be able to finally resolve the issue! Does this sound good? |
Sure @nithusha21, I will do that! |
Hi @nithusha21 @DubeySandeep @bansalnitish Here is the doc for the approaches we have discussed till now: https://docs.google.com/document/d/16ZdhCsBOlFtPpaw5cP2ZTcSOfgZmERJk_eDVROE2GlU/edit?usp=sharing Please provide your inputs here. Thanks! |
Nice work @ankita240796. I went through the doc and to me the tooltip still looks a better choice over the other (considering the pros are same and the corns for modal are high). Let's wait to listen from other two as well. Thanks! |
@nithusha21 could you give your inputs here? |
Hi @ankita240796 The doc looks great! Thanks! I would lean towards the second solution, with a slight modification. Let a comment on the doc. PTAL! |
Hi @nithusha21 @DubeySandeep @bansalnitish I have made the changes as discussed on the doc. Here is working demo for the same: Also, I replaced the title element with tooltip since I was unable to find a way to display the title both on hover and click. This link also mentions that trying to show title on click as well as hover runs a risk of showing two tooltips at the same time. PTAL, Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ankita240796 This looks much better. Thanks! The behavior LGTM. Just some stylistic comments, and queries. PTAL
title="<[getPublishExplorationButtonTooltip()]>"> | ||
uib-tooltip="<[getPublishExplorationButtonTooltip()]>" | ||
tooltip-placement="bottom" | ||
ng-class="{'div-disable': isExplorationLockedForEditing() || countWarnings()}" ng-click="showTooltip()"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is div-disable a standard class you want to use? If not, could you please find a more descriptive name. Maybe something like disable-publish-button or likewise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to use this class both for publish and save draft buttons when they are disabled. Would it be better to use separate names for both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think separate names would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -117,6 +117,13 @@ oppia.directive('explorationSaveAndPublishButtons', [ | |||
$scope.loadingDotsAreShown = false; | |||
}); | |||
}; | |||
|
|||
$scope.showTooltip = function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the function name also include some details about which Tooltip? showTooltip sounds a bit too generic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -69,3 +74,9 @@ | |||
</div> | |||
</li> | |||
</ul> | |||
|
|||
<style> | |||
.div-disable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This style will apply too generally. We should scope it to this specific directive.
.div-disable { | |
exploration-save-and-publish-buttons .div-disable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -117,6 +117,13 @@ oppia.directive('explorationSaveAndPublishButtons', [ | |||
$scope.loadingDotsAreShown = false; | |||
}); | |||
}; | |||
|
|||
$scope.showTooltip = function() { | |||
if ($scope.isExplorationLockedForEditing() || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Break after the opening (
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
title="<[getPublishExplorationButtonTooltip()]>"> | ||
uib-tooltip="<[getPublishExplorationButtonTooltip()]>" | ||
tooltip-placement="bottom" | ||
ng-class="{'div-disable': isExplorationLockedForEditing() || countWarnings()}" ng-click="showTooltip()"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a query. If the button is disabled, will the ng-click event get triggered if clicked? If not when is the showTooltip function triggered? And why do we need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ng-click
on the div element gets triggered since there is no disable on the div.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see. Thanks for the explanation. But on hover itself the tooltip is shown right? how does the click help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the current working, when the user clicks the tooltip is gone but in current scenario, the tooltip stays on click. I am not sure if this is needed since the button is disabled which already implies user cannot click on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the tooltip should show immediately on hover as it does. I think disappearing on click is ok. (I tried on google docs, and their tooltips disappear on click). Also, when disabled, anyway the clicks would not register I think.
After removing, if on clicking the disabled button, the tooltip disappears, then lets keep this functionality. If on clicking the disabled button, the tooltip stays, let's get rid of the ng-clicks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that is the case, we can just use the title attribute and that will work fine. I will update the PR accordingly!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, PTAL!
Also, please note some travis failures. I think what happens is the tooltip for "save draft" stays open on clicking the dropdown arrow, and prevents selecting "discard draft". We need to fix that :) |
Hi @nithusha21, would hiding the tooltip after a small delay be a good solution here? |
I just figured out that changing the placement will fix the issue! |
Hi @nithusha21, I have made the changes, PTAL! |
ng-click="showTooltip()"> | ||
tooltip-placement="right" | ||
ng-class="{'disable-save-button': !isExplorationSaveable()}" | ||
ng-click="showTooltipForDisabledButtons(disable-save-button)"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't disable-save-button be a string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
if ($scope.isExplorationLockedForEditing() || | ||
$scope.showTooltipForDisabledButtons = function(buttonClass) { | ||
if ( | ||
$scope.isExplorationLockedForEditing() || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you indent this line and the next by 2 spaces? This will separate it from the following code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It gives an indentation error: Expected indentation of 14 spaces but found 16 indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok. I wasn't sure if it would do that. Fine to leave as-is.
@@ -3,7 +3,8 @@ | |||
<div class="btn-group" style="margin-right: 10px; margin-top: 8px;" | |||
uib-tooltip="<[getPublishExplorationButtonTooltip()]>" | |||
tooltip-placement="bottom" | |||
ng-class="{'div-disable': isExplorationLockedForEditing() || countWarnings()}" ng-click="showTooltip()"> | |||
ng-class="{'disable-publish-button': isExplorationLockedForEditing() || countWarnings()}" | |||
ng-click="showTooltipForDisabledButtons(disable-publish-button)"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Also, I think the placement down looks better. Every other option has the tooltip downwards. So can we try this, When the dropdown is open, can we hide the tooltip? |
Hi @nithusha21, I have made the changes as suggested as well as fixed the tooltip and dropdown conflict, PTAL! |
56daa4d
to
59ac50f
Compare
Hi Ankita, what was the reasoning behind removing the tooltip though? I thought the tooltip looked better. (also, all other buttons on the top have tooltips.). Lets do this:
Does this sound good? |
Hi @nithusha21, I added the tooltip because it was easy to display that on click rather than a title attribute which was used earlier. If we just want the info on hover then a title attribute does the work, so I removed the tooltip and reverted to the original state of code. Since the title also shows the same bubble as a tooltip and it is in bigger fonts, I feel that title looks better than a tooltip for these two buttons. What do you think? Thanks! |
I didn't actually try out how the title tag works. Let me try it, and i'll let you know. |
Hi @nithusha21, here are some screenshots for clarification: Using tooltip: Using title: |
Yeah I agree visually they look the same. However I seem to prefer the tooltip as it shows up instantly on hover. The title takes a couple of seconds before appearing. So I would go with the tooltip, as it seems to address the original issue. Instantly on hover, the user is prompted with why it is not clickable. Do you agree? |
Also, regarding the click behaviour, I think it is not required. Only the hover behaviour of the tooltip looks to be useful to us. Once prompted that it is not clickable, it is very unlikely that someone will click it. |
Hi @nithusha21, I agree with your opinion on title and tooltip.
I have made the changes as suggested by you, PTAL. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it looks great now! Thanks for fixing this :)
LGTM @ankita240796
Explanation
Fixes #5701
Added mechanism to alert user if user clicks on publish button without saving draft.
Here is a screenshot for the same:
Checklist
python scripts/pre_commit_linter.py
andbash scripts/run_frontend_tests.sh
.