Different states (text and icon) for unaccepted and accepted responses

When changing the helper text to something more actionable (ie. “Mark as solution” vs “Solution”), I have recently discovered that both unaccepted and accepted answers use the same helper text and, by extension, icon. I was wondering if it would be possible to have separate states for when an answer hasn’t been accepted and when a response is marked as a solution, like this:

Button state when an answer has not been selected:
image

Button state on an accepted answer after it is selected.
image

I think users may benefit in seeing helper text that suggests an action than the default “Solution” text. When an answer is selected, it would be helpful to see some evident and feedback as a result of their selection.

Additionally, contextualized hover states may also be helpful in understanding what the button will do, rather than relying on the alt attribute from the browser, see examples below.

Accepting a solution:
Accept Solution Hover and Selection demo

Removing a previously selected answer:
Deselect Solution Hover and Selection demo

Any plans on implementing interactions like these?

2 Likes

I’m adding a css solution in case this is found helpful.

With pseudo elements, at least the behavior for the text portion can be mimicked:

CleanShot 2023-12-08 at 18.56.34

This code is a bit semantically nested, but it works. The text alignment would need to be changed or the button’s width fixed so that the target doesn’t jump around on hover.

css
nav.post-controls .actions button {
    &:after {
        margin-left: 0.5em;
    }
    
    &.unaccepted {
        &:after {
            content: "Mark as solution";
        }
        &:hover {
            &:after {
                content: "Select solution";
            }
        }
        
    }
    
    &.accepted {
        &, .d-icon {
            color: var(--tertiary);
        }
        &:after {
            content: "Selected Solution"; 
        }
        &:hover {
            &, .d-icon {
                color: var(--primary);
            }
            &:after {
                content: "Deselect Solution";
            }
        }
    }
}

It’s also possible to do this, which would result in the text “Select if this reply solves the problem,” which is too long but should respect language translations.

&:after {
    content: attr(title);
}

Ideally, I would change the actual html to support translations, instead of using pseudo elements;
Except for the title attribute (if it was shorter), can be better than having a js hover listener.

2 Likes

Hi @tynaut,

I’m testing out this solution, and I have a question. When one is the original poster, there is an additional button label that is sent to the DOM
Mark as solution which creates duplication with this solution. Do you have any suggestions on how to deal with this? Should I just hide the button label in the CSS?

Thank you!

Hi @tynaut,

I also noticed that there is not an easy way to left-align the buttons so that on hover they don’t jump. The only solution I’ve found is adding a width to the button, which is probably less than ideal given that it’s not a fixed-width element. Do you have any other suggestions for this by any chance?

It is best to combine both measures, because the button will jump indefinitely if the cursor stays at the end of a non-fixed element when the text changes.

nav.post-controls {
    .actions {
        width: 100%;
        .extra-buttons {
            margin-right: auto; // adjusts button to left
            .widget-button {
                width: 200px; // set to value that covers max text
            }
        }
    }
}

CleanShot 2023-12-14 at 10.51.55

You could hide the hover background color and use a different approach to indicate hover if wanted.

DOM text can be set to font-size: 0;.

And the pseudo elements (and the .d-icon class) would need their font-sizes specified since they are children that will inherit that property.

Hey @tynaut, thanks for your help and input.
Is there a way we can change the <use href> property to change the icon for the different states (selected answer, on hover, etc.)?