Skip to content
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

keepPlaceholderOnFocus for Paragraph and Heading when used in a Template #13151

Closed
flod-1 opened this issue Dec 31, 2018 · 6 comments
Closed
Labels
[Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P [Status] Needs More Info Follow-up required in order to be actionable.

Comments

@flod-1
Copy link

flod-1 commented Dec 31, 2018

Use Case
I created a custom block for Gutenberg which makes use of "InnerBlock".
I also added a template in the same step, including some options like "placeholder".
The option "placeholder" itself works fine, but "keepPlaceholderOnFocus" doesn't seem to work in this scenario, as placeholder is removed when focusing the element.

Possible solution
It should be possible to use the option "keepPlaceholderOnFocus" in scenarios like this.

@jorgefilipecosta jorgefilipecosta added [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P Needs Technical Feedback Needs testing from a developer perspective. labels Jan 3, 2019
@youknowriad
Copy link
Contributor

keepPlaceholderOnFocus is a RichText prop, I'm not sure I understand how you'd want to use it in this context? Can you share an example of code?

@youknowriad youknowriad added [Status] Needs More Info Follow-up required in order to be actionable. and removed Needs Technical Feedback Needs testing from a developer perspective. labels Apr 22, 2019
@youknowriad
Copy link
Contributor

Closing as stale. Let's reopen if we can make it actionable.

@flod-1
Copy link
Author

flod-1 commented May 13, 2019

Sorry for the late answer. Following code example:

    blocks.registerBlockType('sbt/milestone', {
        title: 'Milestone Slider Element',
        description: 'Element von Meilenstein Slider',
        icon: 'editor-contract',
        category: 'layout',
        parent: ['sbt/milestones'],
        
        edit: function (props) {
            return (
                el('li', { className: props.className },
                    el(InnerBlocks, {
                        className: 'milestone',
                        template: [
                            ['core/columns', {templateLock: 'all'}, [
                                ['core/column', {templateLock: 'all'}, [
                                    ['core/heading', {
                                        'placeholder': 'Ueberschrift',
					'keepPlaceholderOnFocus': true,
                                        'level': 2,
                                        'align': 'right'
                                    }],
                                    ['core/paragraph', {
                                        'placeholder': 'Beschreibung',
                                        'align': 'right'
                                    }]
                                ]],
                                ['core/column', {templateLock: 'all'}, [
                                    ['core/image', []]
                                ]]
                            ]]
                        ],
                    templateLock: 'all'
                    })
                )
            )
        },
        
        save: function (props) {
            return (
                el('li', { className: 'slider-block' }, 
                    el(InnerBlocks.Content)
                )
            )
        }
    })

Keeping the placeholder when focus on "core/heading" isn't working, when using in this combination. Focus is just removing the placeholder, without entering something. Same for core/paragraph.

@youknowriad
Copy link
Contributor

@floriandagge Where is this code example coming from. keepPlaceholderOnFocus is not an attribute of the heading or paragraph blocks, you can't use this in a template like you're doing here.

@flod-1
Copy link
Author

flod-1 commented May 13, 2019

@youknowriad oh, I'm sorry, I don't know where it was coming from initially. I just double-checked the source, and I'm not sure why I didn't recognize that the whole attribute is not existing in the two blocks. Sorry for that! However, as you can see, it would be very good to implement this attribute. Do you think this can be added?

@youknowriad
Copy link
Contributor

The problem is it's a design decision and attributes are meant to be used for things that persist that are meaningful for the content. I feel like adding this would be too much complexity for a small gain.

An alternative would be to build an alternative block but I can see how this is also too much for such a small change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P [Status] Needs More Info Follow-up required in order to be actionable.
Projects
None yet
Development

No branches or pull requests

3 participants