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

ComboBox plays both the "no change" and selection sound when closed #774

Closed
jbphet opened this issue Jul 8, 2022 · 3 comments
Closed

ComboBox plays both the "no change" and selection sound when closed #774

jbphet opened this issue Jul 8, 2022 · 3 comments
Assignees

Comments

@jbphet
Copy link
Contributor

jbphet commented Jul 8, 2022

While reviewing #768 I noticed that the sound generation behavior for ComboBox has changed. As originally designed, an individual selection sound would be played if the user selected something different, and a generic "close" sound was played if the user opened the ComboBox, then closed it without changing anything. On the current version of master, both the generic and selection-specific sounds are played. This can be easily demonstrated in the current master version of Molarity.

@jbphet jbphet self-assigned this Jul 8, 2022
@jbphet
Copy link
Contributor Author

jbphet commented Jul 8, 2022

From what I can tell, this problem was introduced in 8b4861f. With this change, focusButtonCallback is now being called before setting the property value. Unfortunately, focusButtonCallback also hides the list box. I'm not sure that this is intentional though, because there is a comment several lines later that says "hide the list". Here's what that looks like in context:

      // So that something related to the ComboBox has focus before changing Property value.
      focusButtonCallback();

      // set value based on which item was chosen in the list box
      property.value = listItemNode.item.value;

      // hide the list
      hideListBoxCallback();

The closedNoChange sound player is being triggered by the hiding of the list, and it happens every time now, since the list is becoming invisible before the property change occurs.

@pixelzoom - Since you made this change, I wanted to ask: Is it intentional that the list box be hidden at this point? If so, I can investigate alternative places to identify the list-box-closed-with-no-change situation, but I thought I'd check with you first, since the behavior doesn't seem to quite match the code flow and documentation.

@jbphet jbphet assigned pixelzoom and unassigned jbphet Jul 8, 2022
@pixelzoom
Copy link
Contributor

pixelzoom commented Jul 12, 2022

Yes, 8b4861f was very intentiional. And it's linked to the problem it fixes, #721, which I worked on with @jessegreenberg. Also note the comment that was added above the call to focusButtonCallback.

// So that something related to the ComboBox has focus before changing Property value.
focusButtonCallback();

The sound code seems to be making bad assumptions about when the button receives focus. The button must receive focus whenever the listbox is popped down, regardless of whether a new selection was made. So you probably should not be playing sounds in focusButtonCallback.

@pixelzoom pixelzoom assigned jbphet and unassigned pixelzoom Jul 12, 2022
@jbphet
Copy link
Contributor Author

jbphet commented Nov 28, 2022

This problem has gone away. I dug into the code a bit in an effort to understand why, since it seems like it could potentially come back as easily as it disappeared, but most of the code related to the sound production and the hiding and showing of the list box hasn't changed in a way that would obviously affect this. My best guess is that something changed in the focus code that made it so that focusButtonCallback no longer hides the list box, and it doesn't seem like a good use of my time to track it all the way down. While testing this, I added debug code and could definitively see that the property value is now being set before the list box's visibility is set to false, which is what is needed for the sounds to be correctly produced.

I'll close this, but will my eye out for any odd behavior associated with sound production in combo boxes in this use case.

@jbphet jbphet closed this as completed Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants