-
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
[RNMobile][Android] Fix jumping keyboard when adding a new paragraph using "return" key #28101
Changes from all commits
406a796
a31797f
81d4594
77fc22a
d2e8e06
8b81cd4
206376f
16fd756
665f37e
84cb343
ee8b359
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 |
---|---|---|
|
@@ -19,11 +19,15 @@ function ParagraphBlock( { | |
setAttributes, | ||
mergedStyle, | ||
style, | ||
clientId, | ||
} ) { | ||
const isRTL = useSelect( ( select ) => { | ||
return !! select( 'core/block-editor' ).getSettings().isRTL; | ||
const { isRTL, block } = useSelect( ( select ) => { | ||
const { getBlock, getSettings } = select( 'core/block-editor' ); | ||
return { | ||
isRTL: !! getSettings().isRTL, | ||
block: getBlock( clientId ), | ||
}; | ||
}, [] ); | ||
|
||
const { align, content, placeholder } = attributes; | ||
|
||
const styles = { | ||
|
@@ -53,7 +57,16 @@ function ParagraphBlock( { | |
content: nextContent, | ||
} ); | ||
} } | ||
onSplit={ ( value ) => { | ||
onSplit={ ( value, keepId ) => { | ||
if ( keepId ) { | ||
return { | ||
...block, | ||
attributes: { | ||
...block.attributes, | ||
content: 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. Same question as above 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. Should we do the same for the web version of this file? 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. Yes, we still need the I already added it to the web version :) |
||
if ( ! value ) { | ||
return createBlock( name ); | ||
} | ||
|
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.
Do we really want to have the "keepId" argument? I mean why not just replace the
createBlock( 'core/heading'
call a few lines down 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.
Yes, we still need the
keepId
since it determines if we should use the original block or create a new one. W/o that we wouldn't know if we should create a new block or make changes in the "original" one. I am wondering if I could usegetBlock
in therich-text
component and useonSplit
only for creating new blocks but I'm not sure if it's a good way because we would lose the "flexibility" in that mechanism (currently it could work differently for heading, paragraph, list etc).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.
Adding
keepId
is a horrible API. We should go for one or the other for all cases. Any alternatives we can explore 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.
Can you elaborate a bit? :)
IMHO it is still better than removing the original block and replacing it. Even from the performance perspective update is faster than unmount + mount (we use the
clientId
as a key in our block-list).As I mentioned I was wondering if it could be done inside
rich-text/index.js
. We could get block and change attributes inside instead of callingonSplit
for the original block but i haven't investigated it.