search icon indicating copy to clipboard operation
search copied to clipboard

[Bug] the `selected` card on load functionality does not always have a card selected by default

Open JennySimen opened this issue 3 years ago • 19 comments

Description

When you run the project, a card is selected by default. There is a usecase where no card is selected when the page loads. This is caused by the fact that the card is randomly selected on load. The functionality for generating the randomly selected card uses the length of the engines to get a number as shown below:

engine = engines[Math.floor(Math.random() * engines.length)];

Since js arrays are zero indexed, the number generated from the function above will be in the range [0 - 10] which is 11 search engines instead of [0 - 9] which is 10 search engines.This will provide a usecase where no card is selected on page load because the randomly generated numer is 10 but there are only 0 - 9 search engines

Reproduction

  1. Run the project locally
  2. Reload the project till you find a usecase with no selected card
  3. See error.

Expectation

On every reload, a card should always be selected.

Screenshots

Here is the usecase with no card selected. Screen Shot 2022-10-15 at 12 25 30

Resolution

  • [ ] I would be interested in resolving this bug.

JennySimen avatar Oct 15 '22 11:10 JennySimen

I think this is working now, I have tried it and it selects a card

adetyaz avatar Oct 17 '22 10:10 adetyaz

@adetyaz it still does not always select a card. I can still find the usecase where no card is selected. I have also pulled from upstream to make sure I have the updated code but I still see the bug.

Since the numbers are randomly generated, try reloading multiple times

JennySimen avatar Oct 17 '22 10:10 JennySimen

I'll do that and get back to you on it. @JennySimen

adetyaz avatar Oct 17 '22 11:10 adetyaz

Yes its true, I just experienced it now @JennySimen, after reloading about 5 times.

Can I take a stab at it?

adetyaz avatar Oct 17 '22 11:10 adetyaz

@adetyaz currently, the ticket still has to be evaluated. If the status changes to ready for work, you can ask @possumbilities to assign the ticket to you

JennySimen avatar Oct 17 '22 12:10 JennySimen

Alright thank you.

adetyaz avatar Oct 17 '22 12:10 adetyaz

@possumbilities please I need help, any changes I make to the search.js file doesn't reflect. I have also tried a console.log and alert yet no indication that there has been any changes on the file.

adetyaz avatar Oct 18 '22 11:10 adetyaz

@adetyaz Hi! I'm sorry you're having trouble, when working locally it is likely that your local cache is not clearing when you change the file. You'll have to clear your browser cache after changing the file to make sure the changes are reflected correctly.

possumbilities avatar Oct 18 '22 13:10 possumbilities

Alright, I'll do that and get back on it. thanks @possumbilities.

Side note: when I make changes to text on the interface it changes

adetyaz avatar Oct 18 '22 13:10 adetyaz

@possumbilities, I still experience the same thing, after clearing the cache and using a new browser

adetyaz avatar Oct 20 '22 10:10 adetyaz

@adetyaz Then, I'd suggest you try the CC Community Slack and ask there, to see if anyone else has had a similar issue, and how they resolved it.

possumbilities avatar Oct 20 '22 13:10 possumbilities

Alright thank you

adetyaz avatar Oct 20 '22 13:10 adetyaz

@adetyaz do you have any errors on your console? You can tag me on slack as well so we debug together

JennySimen avatar Oct 20 '22 13:10 JennySimen

@JennySimen yes I have a couple of them

adetyaz avatar Oct 20 '22 13:10 adetyaz

@JennySimen yes I have a couple of them

Get to me on to get more insight

ImaJin14 avatar Oct 20 '22 16:10 ImaJin14

@JennySimen yes I have a couple of them

Get to me on to get more insight

@ImaJin14 we already found the source of the bugs and fixed it. You can check the conversation on slack

JennySimen avatar Oct 20 '22 17:10 JennySimen

@adetyaz The PR of #150 fixes this as well.

Just a heads up

JennySimen avatar Oct 28 '22 11:10 JennySimen

oh okies, seen it. thanks

adetyaz avatar Oct 28 '22 12:10 adetyaz

@possumbilities since there has been no fix for this issue yet can i go on to provide a fix for this or #108 fixes this as well.

JennySimen avatar Nov 03 '22 21:11 JennySimen

Resolved in new site merge: https://github.com/creativecommons/search/pull/206

possumbilities avatar Mar 04 '24 16:03 possumbilities