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

Global Styles: Elements: Link style rules are being applied to buttons #42055

Closed
scruffian opened this issue Jun 29, 2022 · 4 comments · Fixed by #42072
Closed

Global Styles: Elements: Link style rules are being applied to buttons #42055

scruffian opened this issue Jun 29, 2022 · 4 comments · Fixed by #42072
Assignees
Labels
[Block] Buttons Affects the Buttons Block CSS Styling Related to editor and front end styles, CSS-specific issues. [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended

Comments

@scruffian
Copy link
Contributor

scruffian commented Jun 29, 2022

Description

Link rules that are set via theme.json also bleed into button elements on the front end of the site. To overcome this I think we might need to add :not(.wp-element-button) to the link element selector.

Step-by-step reproduction instructions

  1. Switch to emtpytheme
  2. Add this to your theme.json file under elements
			"link": {
				"border": {
					"color": "grey",
					"radius": "1px",
					"width": "5px",
					"style": "solid"
				},
				"color": {
					"background": "lightblue",
					"text": "red"
				},
				"spacing": {
					"padding": "10px"
				},
				"typography": {
					"fontFamily": "sans-serif",
					"fontSize": "20px",
					"textDecoration": "none"
				},
				":hover": {
					"border": {
						"color": "black",
						"radius": "10px",
						"width": "5px",
						"style": "solid"
					},
					"color": {
						"background": "red",
						"text": "black"
					}
				}
			}
  1. Add some buttons blocks
  2. Switch to the front of your site.
  3. Notice that some of the link and hover rules are applying to buttons as well as to links

Screenshots, screen recording, code snippet

Screenshot 2022-06-29 at 16 54 24

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@draganescu
Copy link
Contributor

Tested this, it is visible on the front end.

@draganescu draganescu added [Type] Bug An existing feature does not function as intended [Block] Buttons Affects the Buttons Block [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json CSS Styling Related to editor and front end styles, CSS-specific issues. labels Jun 29, 2022
@draganescu
Copy link
Contributor

Tested this, simply adding :not(.wp-element-button) to ELEMENTS['link'] breaks the hover behavior and the generated style for a:not(.wp-element-button):hover is the same as for a:not(.wp-element-button).

@getdave
Copy link
Contributor

getdave commented Jun 30, 2022

Ok this is an interesting bug. I will look into it now.

@getdave
Copy link
Contributor

getdave commented Jun 30, 2022

I have a suggested fix in #42072. Not sure if the :not() selector route is sustainable in the long term however.

@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Buttons Affects the Buttons Block CSS Styling Related to editor and front end styles, CSS-specific issues. [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants