Skip to content

FIX: make whole details clickable #64142

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

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

renishsurani
Copy link

Why?

Fixes #64116

How?

.wp-block-details {
	box-sizing: border-box;
	position: relative;
}

.wp-block-details summary {
	cursor: pointer;

	&::after {
		content: "";
		position: absolute;
		top: 0;
		left: 0;
		height: 100%;
		width: 100%;
	}
}

Added after to make whole details block clickable.

Screenshots or screencast

Screen.Recording.2024-07-31.at.8.13.37.PM.mov

@renishsurani renishsurani requested a review from ajitbohra as a code owner July 31, 2024 14:45
Copy link

github-actions bot commented Jul 31, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @[email protected].

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: [email protected].

Co-authored-by: jhmonroe <[email protected]>
Co-authored-by: carolinan <[email protected]>
Co-authored-by: renishsurani <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jul 31, 2024
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @renishsurani! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@jhmonroe
Copy link

jhmonroe commented Jul 31, 2024

Why?

Fixes #64116

How?

.wp-block-details {
	box-sizing: border-box;
	position: relative;
}

.wp-block-details summary {
	cursor: pointer;

	&::after {
		content: "";
		position: absolute;
		top: 0;
		left: 0;
		height: 100%;
		width: 100%;
	}
}

Added after to make whole details block clickable.

Screenshots or screencast

Screen.Recording.2024-07-31.at.8.13.37.PM.mov

Hi @renishsurani I'm not an expert on implementation in terms of the best practices for WP Core CSS (I'm a designer and light front-end developer), so I can't be very helpful on how this fits in the big picture.

But, at seeing your video, it looks like the clickable area is where I imagined, but since you didn't hover over the revealed text underneath, I am not sure if your technique causes the revealed paragraph below to also be clickable...?

You may want to test with a longer paragraph or two so everyone can see how it functions with more text.

That was @carolinan 's concern in #64116. Understandably so— since this would also affect instances where someone is not using a background color and that could be unusual for people to see a clickable body paragraph in the middle of an article for instance. (if someone is using this as a standard details expander in the body of long text.

I'd love to have more people weigh in on this who worked on the Details block originally and thought through all the use cases! :-)

PS: Thanks!

@carolinan
Copy link
Contributor

Thank you for trying this @renishsurani.

The problem with this solution is that it only works if there are no interactive elements inside the details.
For example, if you have a link in the content, trying to click on that link only closes the details.
So this is only suitable when you know exactly what is in the details, such as specific client projects or your own site: and not for the default of the block.

@t-hamano t-hamano added [Block] Details Affects the Details Block - used to display content which can be shown/hidden [Type] Enhancement A suggestion for improvement. labels Aug 1, 2024
@renishsurani
Copy link
Author

Thank you for trying this @renishsurani.

The problem with this solution is that it only works if there are no interactive elements inside the details. For example, if you have a link in the content, trying to click on that link only closes the details. So this is only suitable when you know exactly what is in the details, such as specific client projects or your own site: and not for the default of the block.

Okay @carolinan, I understand your point. I will try and let you know if a solution is found.

@jhmonroe
Copy link

jhmonroe commented Aug 7, 2024

It's interesting to see and inspect how Mozilla handles their Details block and applying padding around Summary as well as separately to the bottom of the .extra div(inside the green box on this page):
https://developer.mozilla.org/en-US/docs/Web/CSS/--*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Details Affects the Details Block - used to display content which can be shown/hidden First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Details Block pointer is applied to summary element
4 participants