-
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
Improve consistency of Shared and Permalink blocks UI. #6480
Conversation
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.
Looks good to me and thanks for the speed here.
Should the “Permalink:” label also have the bolder font-weight? |
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 makes it impossible to edit the contents of the shared block, since editing is canceled when clicking outside the panel (into the block contents itself).
} | ||
|
||
handleClickOutside( event ) { | ||
if ( ! this.editForm.current ) { |
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.
When will this be the case?
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 edit form is a separate component and mounted only when editing, If you "click outside" when not editing, then this ref DOM element is null
.
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.
But isn't the callback only bound to the click
event when it is in-fact mounted?
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.
} | ||
|
||
componentDidMount() { | ||
document.addEventListener( 'click', this.handleClickOutside, true ); |
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'd have considered suggesting withGlobalEvents
, though it doesn't support useCapture
. Out of curiosity, why was that needed here?
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.
From the react-click-outside
(which inspired this bit of code) readme: https://github.com/kentor/react-click-outside#details
The enhanceWithClickOutside function wraps the provided component in another component that registers a click handler on document for the event capturing phase. Using the event capturing phase prevents elements with a click handler that calls stopPropagation from cancelling the click event that would eventually trigger the component's handleClickOutside function.
@chrisvanpatten lets maybe check other labels and go with consistency. Either way lets use that as a pattern @afercia. |
bff991d
to
e8de48e
Compare
Rebased to solve merge conflict. |
@aduth I've refactored that check, to make it more clear. |
Ah, interesting. I've missed that the "Edit" button, which is visually associated to the shared block name also gives access to editing the contents of the shared block. A few considerations:
|
Yep, this seems reasonable. The block was originally implemented with a click-outside behavior, and it was removed at some point (I believe as part of nested blocks implementation). Since it's a potentially destructive operation, either accidentally making global changes (if click outside saves) or accidentally losing unsaved changes by a careless click (if click outside cancels), I don't know that click outside is a desirable behavior to support. |
@@ -29,6 +29,7 @@ | |||
|
|||
.editor-post-permalink__label { | |||
margin: 0 10px 0 5px; | |||
font-weight: 600; |
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.
Minor: Could / should we add <strong>
or <b>
as a nested element of the label instead?
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.
Not sure. <strong>
adds a semantic meaning of "strong emphasis" which we don't need here, this element is a label and doesn't need emphasis. <b>
is only presentational, so at this point why not use just CSS?
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.
<b>
actually does have semantic meaning as a "bring attention to" element.
The
<b>
element represents a span of text to which attention is being drawn for utilitarian purposes without conveying any extra importance and with no implication of an alternate voice or mood, such as key words in a document abstract, product names in a review, actionable words in interactive text-driven software, or an article lede.
https://www.w3.org/TR/html53/textlevel-semantics.html#the-b-element
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/b
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.
without conveying any extra importance .. etc.
The b element should be used as a last resort when no other element is more appropriate. In particular, headings should use the h1 to h6 elements, stress emphasis should use the em element, importance should be denoted with the strong element, and text marked or highlighted should use the mark element.
To me, this means it's basically a presentational element to "highlight" some text. So why we should use an additional element? For presentation, CSS is more appropriate. Also, the current official recommendation is HTML 5.2. Instead. 5.3 is still a working draft.
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.
A main worry with styling was that we're not using a variable for the bold value, so if ever the typeface weight changes, there's more instances to update. Can probably be addressed by introducing a variable if it's really an issue.
Should be fine as-is.
Just adding as pinged that I also agree. |
36ffa4c
to
c97e34d
Compare
I've removed the "click outside" behavior: the block name form now closes on Save. As per moving focus when editing, I've tried to change it and still not fully convinced. I'd tend to think the root issue is in the placement of the "Edit" button.: Since it's close to the name form, it's really not so clear that also the shared block content becomes editable. Focusing the name field, makes the previous content hard to get to for keyboard users, as they're forced to reverse-tab. Also, there's no visual indication that the block content is editable:
I'd appreciate some feedback, any thoughts welcome. |
I can't speak to the design / UX impact of separate edit buttons, but so far as shifting focus to the editable content: it seems we lack but could benefit from a consistent programmatic way to focus a block's editable content. Both the Let me know if this sounds reasonable. I could assist with these changes if needed. |
I've played a bit with this. Getting the |
Responding in passing, will give a closer look as I catch up. This may be where we need |
It might be very useful to have it built-in in function logProps(Component) {
class LogProps extends React.Component {
// ...
}
function forwardRef(props, ref) {
return <LogProps {...props} forwardedRef={ref} />;
}
// Give this component a more helpful display name in DevTools.
// e.g. "ForwardRef(logProps(MyComponent))"
const name = Component.displayName || Component.name;
forwardRef.displayName = `logProps(${name})`;
return React.forwardRef(forwardRef);
} There is one blocker, Enzyme version and it's lack of support for React 16.3 ... |
Regarding built-in ref forwarding in
It'd be a fairly breaking change to do directly on |
Given that we usually compose HOCs it should be rather included in the existing helper method. Ideally, we should explore if we can detect if ref was passed and try to forward it or do nothing otherwise. Do you think it would be a breaking change? Do you have any specific use case where you know it would change behavior? So far it was rather a limitation. |
I shouldn't have been so imperative in my statement. Rather than "It'd be a fairly breaking change" I should have written "It might be a breaking change". I'll explore some more and ya I might be able to just detect if ref is already passed. |
Cool, we have time until 3.3 ships (2 weeks?) for breaking changes. In case we need them 😃 Another thing we still didn’t agree on is if we should move a few general HOCs and related helpers from element module to its own module. This was raised a few times because sometimes you need to pull in all components to just use HOC which is a more general concept, on the other hand composing HOCs isn’t really an essential part of element package 🤔 |
@afercia can you update this code so we could review again? |
a4aea06
to
9516744
Compare
Rebased keeping the change from #7987. Screenshot: Note 1: Note 2: |
This PR tries to improve consistency of the Post Permalink and Shared Block UIs, specifically about buttons and interaction.
Screenshot:
Fixes #6469