-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Inline Editor Close Button #5443
Inline Editor Close Button #5443
Conversation
Works fine for me, unit tests were successful. |
Thanks @VizuaaLOG, looks good. @njx we should do the same for color editor as well right? (Tagging @redmunds for the upcoming bezier editor.) |
If we do this in the color editor, we should also do this in WebDocs. |
@VizuaaLOG Take a look at InlineWidget (which is the base class for all the inline editors) and see if you can put it in there in a reasonable way. |
@njx I tried this (b25fd99890ffcae5ecf3ed305a6ed6c78aaa70aa) - the result works for WebDocs, but not for the Inline Editor, because it is would be underneath the scrollbar (not visible). The problem is, we haven't got a default way/element for the InlineWidget. Every (default) extension has its own way to create an InlineWidget. |
// create the close button | ||
var $closeBtn = this.$htmlContent.append("<a href='#'' class='close' id='inline-close'>×</a>"); | ||
|
||
$closeBtn .on("mouseup", function(e) { |
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.
@VizuaaLOG
Please edit your code in Brackets with the default JSLint on. You will see some JSLint errors on this line telling you to have exactly one space after function
and should not have extra white spaces before .on
.
@RaymondLim Fixed the jslint errors. |
@VizuaaLOG Your close button works, but focus gets lost after clicking on it though. If you start typing after using the close button, nothing shows up in the editor. |
|
||
|
||
// create the close button | ||
var $closeBtn = this.$htmlContent.append("<a href='#'' class='close' id='inline-close'>×</a>"); |
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.
You have an extra single quote after href='#'
and this extra quote is causing it to be an invalid element (at least for some jQuery apis). This is why focus gets lost after using the close button.
I fixed the extra quote problem however the focus is still lost when clicking the close button. I thought about doing |
@VizuaaLOG just letting you know we've decided to move the close button to the left so that it can be more consistent with other inline editors and quick doc. Thanks for you help! |
@larz0 Ok, i fixed the focus problem. Also did you want me to commit it on the left or has it already been done? |
|
||
|
||
// create the close button | ||
this.$closeBtn = this.$htmlContent.append("<a href='#' class='close' id='inline-close'>×</a>"); |
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 assignment is wrong. You're assigning the entire inline widget as close button. What you want is create an element with your "a" tag and assign it to the close button before appending it to $htmlContent.
Now with this code you can close the inline editor just clicking anywhere inside the inline.
@VizuaaLOG Larz is informing you to move the button to the left since you're working on it. So we're waiting for your commit. |
@VizuaaLOG yes please :) |
Ok no problem will fix the problem with the entire widget being a close button then will commit the new changes |
Just wondering if someone could help me :). I have changed the close button code to this
However i get the following error in dev tools |
You need to wrap your link element with $() and create an jQuery object and also prefix your variable with $ to indicate that it's a jQuery object. |
Thanks it worked :) Just about to commit the changes |
I think you missunderstood him again (perhaps your method works, but it isn't nice). Maybe take a look at 0523bc6. |
|
||
|
||
// create the close button | ||
var closeBtn = $("<a href='#' class='close' id='inline-close'>×</a>"); |
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's better to keep it as this.$closeBtn
instead of a local variable. Also it is important to prefix with a $
if it is a jQuery object and not a regular HTML element.
@RaymondLim ok will change it now also is @SAplayer's method better because i think it looks cleaner so i will change it to that. |
Yes, @SAplayer's code is better as you're chaining to the existing code with the new close button first. |
// create the close button | ||
this.$closeBtn = this.$htmlContent.find("#inline-close"); | ||
this.$closeBtn.click(function (e) { | ||
console.log("Clicked"); |
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.
No, please don't leave your debugging code in.
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.
Yes sorry i noticed it after i committed it so i'm just undoing it then re committing
I think that is everything. I had to re commit the style because i undid the commits too far :(. But it all works again. |
.append("<div class='shadow bottom' />"); | ||
|
||
.append("<div class='shadow bottom' />") | ||
.append("<a href='#' class='close' id='inline-close'>×</a>"); |
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.
We can't use an id here because there can be multiple inline editors open at once. If you change this to a class it should work fine.
But it seems like you could just use the existing .close
class on this node -- the find() call below should still work since it's scoped, and the CSS rule below is already nested under a .inline-widget
selector as well.
I have changed it to use the class and removed the ID and it all still works. |
.append("<a href='#' class='close'>×</a>"); | ||
|
||
// create the close button | ||
this.$closeBtn = this.$htmlContent.find('.close'); |
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.
Nit: Please use double quote for strings as this is our coding convention.
@RaymondLim Sorry i changed it, need to get used to that because i usually use single quotes. |
Looks good now. Merging. |
Ok thanks. |
🍻 |
Oops... Looks like this breaks one of the WebPlatformDocs extensions unit tests. File a new issue #5473 for the unit test failure. |
I just checked this out and it looks fine everywhere except Quick Docs, where it seems to be causing the content in the right column to shift downward. Filed as #5472. |
I just looked at the problem and it is the margin right to move the content away from the close button. However, i cant think of another way to move the content away from the button. Any ideas? |
@VizuaaLOG I'll take a look. |
Found the problem and will make a branch to fix it |
See comments in #5472. I don't think it's necessarily the margin's fault--it might be the fact that we're adding a float into the top level. |
i tried getting rid of the float and it didn't change. The fix i had was changing the left columns's width to 26% which fixes the problem. However i'm new to git and am having some teething troubles with it so i cant fix it :). Will get my git fixed tomorrow then try then |
@VizuaaLOG sounds good :) |
I have added a close button to the inline editor as was requested here #5441. The unit test was successful. Please review the work and leave any feedback.