-
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
Add No Follow toggle to Link Control #48722
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -16,7 +16,7 @@ export default function useInternalInputValue( value ) { | |||||
if ( value && value !== internalInputValue ) { | ||||||
setInternalInputValue( value ); | ||||||
} | ||||||
}, [ value ] ); | ||||||
}, [ internalInputValue, value ] ); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Please can we revert this change and use the eslint syntax to disable the warning? The original code is clearly faulty (that is my fault) but we should avoid overcomplicating this PR by adding the dep here. I will raise a separate Issue to fix this problem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once we revert this change we might see tests passing again 🤞 |
||||||
|
||||||
return [ internalInputValue, setInternalInputValue ]; | ||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -42,6 +42,9 @@ const LinkSettingsScreen = ( { | |||||
const [ opensInNewWindow, setOpensInNewWindows ] = useState( | ||||||
activeAttributes.target === '_blank' | ||||||
); | ||||||
const [ markedAsNoFollow, setMarkedAsNoFollow ] = useState( | ||||||
( activeAttributes.rel = 'nofollow' ) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Are there other options for this we need to consider? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say let's keep the PR's simple and small, we can always add more later but that prevents them from getting to complex or going stale There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No sorry I was thinking if the attributes have other settings on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 to what @getdave asks as it is now it doesn't work because it expects a boolean value for |
||||||
); | ||||||
const [ linkValues, setLinkValues ] = useState( { | ||||||
isActiveLink: isActive, | ||||||
isRemovingLink: false, | ||||||
|
@@ -64,7 +67,7 @@ const LinkSettingsScreen = ( { | |||||
onHandleClosingBottomSheet( () => { | ||||||
submit( inputValue, { skipStateUpdates: true } ); | ||||||
} ); | ||||||
}, [ inputValue, opensInNewWindow, text ] ); | ||||||
}, [ inputValue, opensInNewWindow, markedAsNoFollow, text ] ); | ||||||
|
||||||
useEffect( () => { | ||||||
const { isActiveLink, isRemovingLink } = linkValues; | ||||||
|
@@ -99,6 +102,7 @@ const LinkSettingsScreen = ( { | |||||
const format = createLinkFormat( { | ||||||
url, | ||||||
opensInNewWindow, | ||||||
markedAsNoFollow, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Since the names are different we should update it so the right value gets to |
||||||
text: linkText, | ||||||
} ); | ||||||
let newAttributes; | ||||||
|
@@ -213,6 +217,15 @@ const LinkSettingsScreen = ( { | |||||
onValueChange={ setOpensInNewWindows } | ||||||
separatorType={ 'fullWidth' } | ||||||
/> | ||||||
<BottomSheet.SwitchCell | ||||||
icon={ external } | ||||||
label={ __( | ||||||
'Search engines should ignore this link (mark as nofollow)' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a bit long for mobile so maybe we could use just the part "No follow" as suggested in this comment. |
||||||
) } | ||||||
value={ markedAsNoFollow } | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we are using the |
||||||
onValueChange={ setMarkedAsNoFollow } | ||||||
separatorType={ 'fullWidth' } | ||||||
/> | ||||||
<BottomSheet.Cell | ||||||
label={ __( 'Remove link' ) } | ||||||
labelStyle={ styles.clearLinkButton } | ||||||
|
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.
Let's extend this and then make changes within
settings.js
to optionally include thehelp
prop on theToggleControl
.